python中的input函数和raw_input函数的区别
来源:互联网 发布:pk10网站源码 编辑:程序博客网 时间:2024/05/22 14:56
input()和raw_input()函数的区别:
首先,说明eval函数:eval函数的参数必须是字符串形式。eval函数是将字符串转换为算式运算。
如:1. 参数为空,出错。
2. 说明参数必须为字符串string对象。
3. eval函数将字符串转换为算式表达式求值,会在历史记录(局部空间,全局空间)寻找变量名的值。如x的值。
其次,input函数。
input函数是输入函数,如果输入的变量为字符串或字符,且该变量名在历史记录中有过赋值,则正确。 否则出错。 输入整数,正确。
最后,raw_input函数,是将输入的变量以字符串存储起来。输入值都正确。不会出错。raw_input函数比input函数更通用。
The arguments are a Unicode or Latin-1 encoded string and optional globals and locals. If provided,globals must be a dictionary. If provided, locals can be any mapping object.
input([prompt])
Equivalent to eval(raw_input(prompt)).
If the input is not syntactically valid, a SyntaxError will be raised. Other exceptions may be raised if there is an error during evaluation.
If the readline module was loaded, then input() will use it to provide elaborate line editing and history features.
Consider using the raw_input() function for general input from users.
raw_input([prompt])
If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read,EOFError is raised. Example:
>>> s = raw_input('--> ')--> Monty Python's Flying Circus>>> s"Monty Python's Flying Circus"
If the readline module was loaded, thenraw_input() will use it to provide elaborate line editing and history features.
- python中的input函数和raw_input函数的区别
- python input函数和raw_input函数的区别
- Python中的eval(),raw_input()和input()函数
- python input 与raw_input函数的区别
- python input 与raw_input函数的区别
- 输入函数input()和raw_input()的区别
- Python中input()函数与raw_input()函数的区别
- Python中内建函数input()与raw_input()函数的区别
- python input()函数和raw_input()函数差别
- python input,raw_input函数
- Python输入函数:raw_input() 与 input() 的区别
- python中raw_input()以及input()函数的区别
- pyhon中input()和raw_input()函数的区别
- python2.x里面的input()和raw_input()函数以及3.x中的input()函数的区别
- 【Python】Python input和raw_input的区别
- 函数raw_input()与input()的区别
- Python input和raw_input的区别
- Python input和raw_input的区别
- 背景音乐实现功能
- Hibernate中update方法的注意点
- android EditText默认问题
- win8.1下无法运行vc++6.0的解决方法
- 关于CentOS网络连接问题及第三天实习收获
- python中的input函数和raw_input函数的区别
- 二叉树的前序、中序、后序、层序遍历
- Kaprekar数
- Integer Partition(hdu4658)2013 Multi-University Training Contest 6 整数拆分二
- MySQL存储引擎总结
- HQL和SQL的区别
- Java 内存分配全面浅析
- android LayoutInflater 的使用
- QTreeWidget样式设置大全(一)