简体   繁体   English

如何在 Windows 命令提示符下运行 python 文件?

[英]How to run a python file in the windows command prompt?

I was trying to run the python file in the windows command prompt, and I used the command "test.py" , with the double quotes in the command.我试图在 windows 命令提示符下运行 python 文件,我使用了命令"test.py" ,命令中带有双引号。

The file was opened as a .txt file with the codes I wrote in it instead of running like a program.该文件以.txt文件的形式打开,其中包含我在其中编写的代码,而不是像程序一样运行。

I have put the file on the desktop.我已经把文件放在桌面上了。

I am very new to coding.我对编码很陌生。 Can someone help me with how to run python file from windows cmd prompt?有人可以帮助我如何从 Windows cmd 提示符运行 python 文件吗?

Have you tried running你试过跑步吗

python "/path/to/file.py" ? python "/path/to/file.py"

For python 3, you may have to use对于python 3,您可能必须使用

python3 "/path/to/file.py"

Instead of writing:而不是写:

"test.py"

Use

python test.py

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM