Python学习笔记(一)--- Python 解释器

Using Python Interpreter

1. Perhaps the quickest check to see whether command line editing is supported is typeControl-P to the first Python prompt you get. If it beeps, you have command line editing. If nothing appears to happend, or if ^p is echo, command line editing isn't available, you'll only be able to use backspace to remove characters from the current line.
也许检查是否支持“命令行编辑”的最快方法是,在你的第一个Python提示符后键入Control-P。如果听见“哔”,那么支持“命令行编辑”。如果什么都没有发生或者显示^p,那么不支持“命令行编辑”,你只能使用退格来删除当前命令行的字符。

2. 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 status. If that doesn't work, you can exit the interpreter by typing the following command:quit().
在主提示符后键入“文件结束符”(Unix中为Control-D, Windows中为Control-Z)将导致解释器以“零状态”退出(正常退出)。如果这样做不起作用,你可以键入命令quit()来退出解释器。

3. When known to the interpreter, the scripts name and additional arguments thereafter are turned into a list of strings and assigned to the argv variable in the sys module. The length of the list is at least one; when no script and no arguments are given, sys.argv[0] is an empty string.
当解释器知道的时候,脚本名和附加的参数名将被装入一个字符串列表中,并赋予sys模块的argv变量。这个列表的长度至少是一;当没有脚本和参数时,sys.argv[0]是一个空字符串。

4. Be default, Python source files are treated as encoded in UTF-8. To declare an encoding other than the default one, a special comment line should be added as the first line of the file. The syntax is as follow:
默认情况下,Python的源文件是使用UTF-8编码的。若要声明一个与默认编码不同的编码,需要在文件的第一行添加一条特殊的注释。语法如下:

# -*- coding: <encoding> -*-
5. One exception to the first line rule is when the source code starts with a Unix "shebang" line. In this case, the encoding declartion should be added as the second line of the file.
编码声明的“第一行”规则有一个例外:当源码以Unxi的“shebang”行开始的时候,编码声明将作为文件的第二行。例如:
#!/usr/bin/env python3

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值