本文摘自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的比较的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
爬虫为什么不用java要用 Python
Python工作好找吗
Python 2 map() reduce()函数用法讲解
Python把二维数组输出为图片的方法
Python32位和64位有什么区别
Python切片索引用法
如何在线运行Python
Python安装库安装失败怎么解决
Python eval的常见错误封装及利用原理的介绍
Python实现堆栈与队列功能(基于list的append与pop方法)的示例
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » Python中关于input和raw_input的比较