简体   繁体   English

Python IDLE Shell令人困惑的问题

[英]Perplexing issue with Python IDLE Shell

Absolute novice with programming. 绝对是编程新手。 Apparently I was wasting a members time with 10 words about myself so here is my edit and question sans any personality. 显然我在浪费成员时间,只说了10个关于我自己的单词,所以这是我的编辑和提问,没有任何个性。 :) :)

This morning, I opened up my laptop to practice (Mac OS 10.11.6). 今天早上,我打开笔记本电脑进行练习(Mac OS 10.11.6)。 Reopened IDLE and the files from yesterday and continued practicing when I noticed the shell was not outputting anything unless I told it to print. 重新打开了IDLE和昨天的文件,并继续练习,直到我发现shell除非我要打印,否则不会输出任何内容。 In the editor I have: 在编辑器中,我有:

1-1
x_list = [1,2,3]
x_list
print(x_list)

The shell returns this: Shell返回以下内容:

    >>> 
 RESTART: /Users/plaksatyler/Desktop/Python Practice Code/Do Not Give Up/GibberishTest.py 
>>> 
 RESTART: /Users/plaksatyler/Desktop/Python Practice Code/Do Not Give Up/GibberishTest.py 
>>> 
 RESTART: /Users/plaksatyler/Desktop/Python Practice Code/Do Not Give Up/GibberishTest.py 
[1, 2, 3]
>>> 

I've removed and reinstalled IDLE two times, upgraded PIP and ran the Shell update command because I have no clue what to do. 我已经删除并重新安装了两次IDLE,升级了PIP并运行了Shell更新命令,因为我不知道该怎么做。 Any ideas would be greatly appreciated. 任何想法将不胜感激。 Thanks! 谢谢!

Screenshot 截图

This is not a glitch. 这不是小故障。 When you are running programs from a file, only things that you tell it to print will be printed. 从文件运行程序时,只会打印您告诉它要打印的内容。

When you run it by typing in the lines (with the >>> ), all of the results will be printed. 当您通过输入行(带有>>> )来运行它时,将打印所有结果。

Imagine how annoying it would be if every single line produced output in IDLE. 想象一下,如果每行都在IDLE中产生输出,那将是多么烦人。 Usually you only need to output things like results or messages. 通常,您只需要输出诸如结果或消息之类的内容。

If you want to use IDLE as a "programming calculator", you can just type everything into the shell (AKA >>> window), not the editor. 如果要将IDLE用作“编程计算器”,则只需将所有内容键入外壳程序(又名>>>窗口),而不是编辑器即可。

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

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