python的交互式解释器_1.2Python交互式解释器

Posted by 撒得一地 on 2015年11月10日 in python教程

国外稳定加速器推荐

vypr |

Nord

alyad.png

在window下,当启动python时,会出现和下面相似的提示:

Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:37:12) [MSC v.1600 32 bit (In

tel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>>

注意:这里解释器的准确外观和错误信息都取决于当前python版本。

python交互式解释器和linux的shell很相似,感觉瞬间进入了"黑客殿堂"—这是你控制计算机的第一步。

运行第一个python语句,输入下面的命令看看它是否能正常工作:

>>> print('hello world!')

当你按下回车键,会有下面的输出:

hello world!

注意:如果熟悉了其它计算机语言,可能会习惯每个语句以分号来结束。不过,Python则不用,一行就是一行,不管多少。不过可以加上分号,但是不会有任何作用(除非同一行还有更多代码),而且这也不是通行做法。

解释器上的>>>符合是提示符,表示可以在后面写点什么语句来执行。当你按下回车,命令执行成功后,下一行又会出现一个新的提示符。

当你在提示符后输入无效语句,就会提示出错,比如:

>>> for test

File "", line 1

for test ^

SyntaxError: invalid syntax

显然,解释器不明白输入为何物,不过解释器能够指出哪里地方出错了。你可以输入help()命令尝试获得帮助,然后输入quit退出帮助。比如:

>>> help()

Welcome to Python 3.3! This is the interactive help utility.

If this is your first time using Python, you should definitely check out

the tutorial on the Internet at http://docs.python.org/3.3/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing

Python programs and using Python modules. To quit this help utility and

return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",

"keywords", or "topics". Each module also comes with a one-line summary

of what it does; to list the modules whose summaries contain a given word

such as "spam", type "modules spam".

help> quit

You are now leaving help and returning to the Python interpreter.

If you want to ask for help on a particular object directly from the

interpreter, you can type "help(object)". Executing "help('string')"

has the same effect as typing a particular string at the help> prompt.

总的来说,python还是比较有意思的。

... other posts by psz1992

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值