本文摘自php中文网,作者黄舟,侵删。
这篇文章主要介绍了Python中input与raw_input 之间的比较的相关资料,通过本文希望能帮助到大家,对于他们之间的使用方法和区别,需要的朋友可以参考下Python中input与raw_input 之间的比较
input和raw_input均可以接收输入,其差别如下所示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | >>> name = input ( "what is your name?" )
what is your name?ZJ
Traceback (most recent call last):
File "<stdin>" , line 1 , in <module>
File "<string>" , line 1 , in <module>
NameError: name 'ZJ' is not defined
>>> name = input ( "what is your name?" )
what is your name? "ZJ"
>>> print name
ZJ
>>>
>>> name = raw_input ( "what is your name?" )
what is your name?ZJ
>>> print name
ZJ
>>>
|
因此,一般情况下应尽可能的使用raw_input。
以上就是Python中关于input和raw_input的比较的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
Python一键搭建http服务器的方法
认识Python对象自省机制
Python中(urlparse)模板的使用详解
Python变量与赋值的图文详解
ubuntu怎么安装Python
Python爬虫防止ip被封的方法
非常实用的Python小技巧总结
Python range函数怎么用
Python中socket实现udp通信的介绍(附代码)
Python使用代理ip访问网站
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » Python中关于input和raw_input的比较