在 Windows 中运行 python 脚本 [英] Run a python script in windows
问题描述
我一直使用 mac 来编写和运行 python 脚本.但是,我在 PC 上有一堆文件需要在其上运行脚本.我从未真正使用过 PC,也不知道如何运行脚本.
I have always used a mac to write and run python scripts. However, I have a bunch of files on a PC that I need to run a script on. I have never really used a PC and don't know how to run the script.
如果我转到 PC 上的 command
程序并输入 python
,则没有任何反应.如何找到 python 路径以进入 python 提示
?另外,一旦我进入提示符,modules
的导入是否与 Unix
系统中的导入相同?
If I go to the command
program on the PC and type in python
, nothing happens. How do I find where the python path is in order to get into the python prompt
? Also, once I am in the prompt, is the importing of modules
the same as in a Unix
system?
推荐答案
Python 不会默认添加到 Windows 系统环境的 PATH 变量中.您必须将包含 Python.exe 文件的目录的路径添加到 PATH 变量中,或者显式调用 python.
Python isn't added to the system environment's PATH variable by default on windows. You have to either add the path to the directory containing the Python.exe file to the PATH variable, or call python explicitly.
此问题已在 Python 文档中解决:Python 文档:# How在windows下运行Python程序
This issue has been addressed in the Python documentation: Python Documentation: # How to run a Python program under windows
这篇关于在 Windows 中运行 python 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!