在空闲状态下编码和终端编码有什么区别?

2024-04-26 12:06:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我安装了Python2.7,我有它的空闲版本。我还使用python3和python2的终端和conda创建了两个环境。在

当我输入python时,它显示我使用的是python3.5.2。现在:

  1. 如何在空闲或终端的两个版本之间切换?在
  2. 在空闲状态下编码和在终端中编码有什么区别?在

Tags: 版本终端编码环境状态condapython3空闲
1条回答
网友
1楼 · 发布于 2024-04-26 12:06:20
  1. 不能从Python内部切换Python版本。IDLE运行在Python的任何版本之上,并且不能切换运行它的版本。您可以在python2.7上同时运行IDLE 2.7,在python3.5上同时运行IDLE 3.5。在

当您从任何空闲编辑器运行代码时,它会添加您的File=>;Recent files列表,该列表用于您运行的任何空闲版本。我经常把一个文件拉到另一个运行的版本中,看看它是否运行相同,也许是在2.7和3.x之间的已知差异进行了修订之后

  1. 人们编写的代码中至少有95%是直接在Python中运行的(带有-i标志)和空闲代码。IDLE doc(可在Help=>;IDLE Help下访问)注意到这些差异。在

3.2. IDLE-console differences

As much as possible, the result of executing Python code with IDLE is the same as executing the same code in a console window. However, the different interface and operation occasionally affects visible results. For instance, sys.modules starts with more entries.

IDLE also replaces sys.stdin, sys.stdout, and sys.stderr with objects that get input from and send output to the Shell window. When this window has the focus, it controls the keyboard and screen. This is normally transparent, but functions that directly access the keyboard and screen will not work. If sys is reset with importlib.reload(sys), IDLE’s changes are lost and things like input, raw_input, and print will not work correctly.

With IDLE’s Shell, one enters, edits, and recalls complete statements. Some consoles only work with a single physical line at a time. IDLE uses exec to run each statement. As a result, 'builtins' is always defined for each statement.

我应该补充一些同样深奥的东西。在

相关问题 更多 >