python3解释器执行not 1 and 1_Python3.9官方文档翻译版之解释器的使用1

Using the Python Interpreter(解释器的使用)

Invoking the Interpreter(解释器的安装)

The Python interpreter is usually installed as /usr/local/bin/python3.9 on those machines where it is available; putting /usr/local/bin in your Unix shell’s search path makes it possible to start it by typing the command :

自译:Python解释器通常安装在机器的可用路径为“/usr/local/bin/python3.9”,将“/usr/local/bin”置于你的UNIX shell的搜索路径中通过键入“python 3.9”的命令来启动它。

to the shell. Since the choice of the directory where the interpreter lives is an installation option, other places are possible; check with your local Python guru or system administrator. (E.g., /usr/local/python is a popular alternative location.)

自译:由于解释器的安装路径是可以自主设置的,所以你可以使用系统管理员的权限进行安装路径的设置(例如"/usr/local/python"是一个比较通用的安装路径)

On Windows machines where you have installed Python from the Microsoft Store, the python3.9 command will be available. If you have the py.exe launcher installed, you can use the py command. See Excursus: Setting environment variables for other ways to launch Python.

自译:在Windows机器上你可以通过微软软件商店进行python安装,这样python3.9的命令可以直接被使用。如果你通过.exe执行文件安装的话,你可以使用python命令进行使用。为了可以登录使用python对于环境变量的设置可以参见附件。

Typing an end-of-file character (Control-D on Unix, Control-Z on Windows) at the primary prompt causes the interpreter to exit with a zero exit status. If that doesn’t work, you can exit the interpreter by typing the following command: quit().

自译:在主命令行中输入结束字符可以退出解释器登录状态(Unix点击Ctrl + d,Windows系统点击Ctrl + z)。如果它不工作了,你可以通过敲击”quit()”命令退出解释器。

The interpreter’s line-editing features include interactive editing, history substitution and code completion on systems that support the GNU Readline library. Perhaps the quickest check to see whether command line editing is supported is typing Control-P to the first Python prompt you get. If it beeps, you have command line editing; see Appendix Interactive Input Editing and History Substitution for an introduction to the keys. If nothing appears to happen, or if ^P is echoed, command line editing isn’t available; you’ll only be able to use backspace to remove characters from the current line.

自译:解释器的行编辑功能包含交互式编辑、历史替换和支持GNU读行库的系统上完成编码。检查能够进行行编辑最好的方式是输入Ctrl + P。

如果发出嗡鸣提醒,那么你可以进行命令行编辑;请参阅附录交互式输入编辑和历史记录替换以了解这些键的介绍。

如果没有出现任何情况,出现的是^p,那么命令行编辑不可用;你只能使用退格键从当前行中删除字符。

The interpreter operates somewhat like the Unix shell: when called with standard input connected to a tty device, it reads and executes commands interactively; when called with a file name argument or with a file as standard input, it reads and executes a script from that file.

自译:解释器的操作有些像Unix shell:当连接tty设备的标准输入被调用时,它以交互的方式读取和执行命令;当以文件名被调用或以一个文件作为标准输入被调用时,它从哪个文件读取并执行脚本。

A second way of starting the interpreter is python -c command [arg] ……, which executes the statement(s) in command, analogous to the shell’s -c option. Since Python statements often contain spaces or other characters that are special to the shell, it is usually advised to quote command in its entirety with single quotes.

自译:启动解释器的第二种方式是输入 python -c 命令,它会在命令中执行语句,类似于shell中的“-c”操作。由于python语句通常包含空格和其他区别于shell的其他特征,所以通常被建议在它的整体加上单引号。

Some Python modules are also useful as scripts. These can be invoked using python -m module [arg] ……, which executes the source file for module as if you had spelled out its full name on the command line.

自译:一些python模块可以作为脚本使用。可以使用”python - m 模块”来调取。如果你已经在命令行中拼出全部的名字运行后,它将当作模块使用一样去执行这些源文件。

When a script file is used, it is sometimes useful to be able to run the script and enter interactive mode afterwards. This can be done by passing -i before the script.

自译:当脚本文件被使用时,它时长被用来确保运行脚本文件并且在之后进入交互模式。也可以在脚本之前通过 “-i”来完成它。

All command line options are described in Command line and environment.

自译:所有的命令行操作命令行和环境中执行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值