简体   繁体   English

如何在终端中的原子中运行python代码?

[英]how to run python code in atom in a terminal?

我是编程和原子的初学者,所以当尝试在终端中运行以原子编写的python代码时,我不知道如何...我尝试安装像run-in-terminal,platformio-ide-terminal这样的程序包,但我不知道如何使用它们。

  1. Save your Script as a .py file in a directory. 将您的脚本另存为目录中的.py文件。
  2. Open the terminal and navigate to the directory containing your script using cd command. 打开终端,并使用cd命令导航到包含脚本的目录。
  3. Run python <filename>.py if you are using python2 如果使用的是python2,请运行python <filename>.py
  4. Run python3 <filename.py> if you are using python3 如果您正在使用python3,请运行python3 <filename.py>

I would not try to do it using extensions. 我不会尝试使用扩展来做到这一点。 I would use the platformio-ide-terminal and just do it from the command line. 我将使用platformio-ide-terminal并仅从命令行执行。

Just type: Python script_name.py and it should run fine. 只需输入:Python script_name.py,它应该可以正常运行。 Be sure you are in the same directory as your python script. 确保您与python脚本位于同一目录中。

"python filename.py" should run your python code. “ python filename.py”应运行您的python代码。 If you wish to specifically run the program using python 3.6 then it would be "python3.6 filename.py". 如果您希望使用python 3.6专门运行该程序,则应为“ python3.6 filename.py”。

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

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