简体   繁体   English

命令提示符中的 Python 不起作用,但在 python 空闲时它可以

[英]Python in command prompt doesn't work, but in python idle it does

When running the code in command prompt I get this result: Command Prompt在命令提示符下运行代码时,我得到以下结果:命令提示符

But when I run it in python idle the game runs fine.但是当我在 python 空闲运行它时,游戏运行良好。 Idle闲置的

Heres the file location: Location继承人文件位置:位置

Copy the following at the beginning of your code to set the working directory to the same as the script's directory:在代码开头复制以下内容以将工作目录设置为与脚本目录相同:

import os
os.chdir(os.path.dirname(os.path.abspath(__file__)))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么这在Python IDLE shell中有效,但在我从命令提示符下作为Python脚本运行时却没有? - Why does this work in the Python IDLE shell but not when I run it as a Python script from the command prompt? 命令提示符中的“python”不起作用(Windows 10) - "python" in command prompt doesn't work (windows 10) 命令提示符中的Python套接字错误,但不处于空闲状态 - Python socket error in command prompt but not in idle Python IDLE不起作用,因为缺少python.exe - Python IDLE doesn't work because python.exe is missing 具有open('filename')的Python脚本可用于IDLE,但不能在控制台中使用 - Python script with open('filename') works with IDLE but doesn't work in console 我的 python 文件在 cmd 中完美运行,但在 IDLE 中无法运行 - My python file works perfectly in cmd, but doesn't work in IDLE pygame.mouse.get_pos()不起作用(Python IDLE 3) - pygame.mouse.get_pos() doesn't work (Python IDLE 3) python IDLE斐波那契序列我的模型不起作用 - python IDLE fibonocci sequence my model doesn't work 为什么命令 Python 在命令提示符中不执行任何操作? - Why doesn't the command Python not do anything in Command Prompt? 使用鼠标右键>>在此处命令提示符后执行脚本时,Python无法正常工作 - Python doesn't work properly when I execute a script after using Right Click >> Command Prompt Here
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM