如何在 Windows 上的命令提示符中获取 python?
我刚刚在 Windows 7 上安装了 Python。我以为之后我就可以在命令提示符下运行 python,但事实并非如此。安装后我还发现我可以运行python命令shell。这很好。但是如果我想将我的程序保存在一个文件中,然后我想运行这个程序(例如在Linux中,我在命令行中输入“python file_name.py”),我该怎么办?
I have just installed Python on my Windows 7. I thought that after that I will be able to run python on the command prompt but it is not the case. After the installation I also found out that I can run the python command shell. This is nice. But what should I do if I want to save my program in a file and then I want to run this program (in Linux, for example, I typed "python file_name.py" in the command line).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要将 python bin 目录添加到您的路径中。按照此处的说明操作并添加
c :\python26\bin
到路径(除非您在非默认位置安装了 python)。You need to add the python bin directory to your path. Follow the instructions here and add
c:\python26\bin
to the path (unless you installed python in a non-default location).python.exe 在你的 Windows 路径中吗?尝试查看 PATH 环境变量,看看其中是否列出了 python 的安装文件夹。
Is python.exe in your windows path? Try to look at the PATH environment variable and see if the installation folder of python is listed there.
您需要更新环境变量以包含 Python 可执行文件的路径。
在 XP 上,您可以通过右键单击“我的电脑”-> 来完成此操作。属性,然后转到“高级”选项卡。
You need to update your environment variables to include the path to the Python executable.
On XP you can do this by right clicking on "My Computer" -> Properties and then going to the "Advanced" tab.