简体   繁体   English

命令提示符Python

[英]Command Prompt Python

What is the benefit of running code through the command prompt/terminal vs an ide? 通过命令提示符/终端运行代码与ide相比有什么好处?

I've noticed recently when using the progressbar module of python that the progress text is updated on the same line in the command prompt window while the ide prints each text on the next line. 我最近注意到,当使用python的progressbar模块时,进度文本将在命令提示符窗口的同一行上更新,而ide将在下一行上打印每个文本。 Why are these different? 为什么这些不同? Are they not running though the same interpreter? 他们不是通过同一个解释器运行吗?

The IDE adds an extra layer of software between the program and the python interpreter. IDE在程序和python解释器之间添加了额外的软件层。

What you are seeing is probably that the IDE's output window is not a complete terminal emulator, and doesn't understand or ignores the commands that the progressbar module uses. 您所看到的可能是IDE的输出窗口不是完整的终端仿真器,并且不了解或忽略progressbar模块使用的命令。 to keep the output on the same line. 保持输出在同一行。

Have a look at ipython . 看看ipython It is a very nice environment for testing and running python code. 它是用于测试和运行Python代码一个非常好的环境。

每个IDE实际上都是通过命令行进行交互,并将流重定向到显示这些输出的实现中,每个IDE都有其自己的方式,如果您经验丰富并且易于尝试一个脚本,请尝试使用命令提示符更强大,请尝试使用ipython,对于初学者和学习者都非常适合,以便快速访问编程环境并试用模块。

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

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