【个人笔记】python input() xx is not defined
来源:互联网 发布:软件冗余技术 编辑:程序博客网 时间:2024/06/07 10:58
Eli:刚开始学python,慢慢记笔记。
----------------------------------------------------------------------------------------------------------------
input() xx is not defined
>>> spam = input()
101
>>> spam
'101'
在很多书里刚刚教input时都是这样写的。但是实际上运行起来。
>>> spam = input()
101
---------------------------------------------------------------
NameError
<python-input-xx-xxxxxxxxxxxxxx> in <module>()
----> 1 spam = input()
NameError: name '101' is not defined
>>>spam
---------------------------------------------------------------
NameError
<python-input-xx-xxxxxxxxxxxxxx> in <module>()
----> 1 spam = input()
NameError: name '101' is not defined
其实python希望读取一个合法的 python 表达式,即输入字符串的时候必须使用引号将它括起来。--高亮处英文
https://docs.python.org/2/library/functions.html#input
input
([prompt])Equivalent to eval(raw_input(prompt))
.
This function does not catch user errors. If the input is notsyntactically 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(),这个就符合我们刚开始想象中的输入方式:
>>> spam = raw_input()
101
>>> spam
'101'
- 【个人笔记】python input() xx is not defined
- bug宝典Python篇 NameError: name 'xx' is not defined
- python中input输出“Name 'XXX' is not defined问题
- python raw_input or input With name 'abc' is not defined
- python : raw_input is not defined
- Customer xxxx is not defined for function xx
- 火狐反复提示ReferenceError: xx is not defined
- python NameError: name 'raw_input' is not defined
- 【Python】NameError:name ‘xrange’ is not defined
- 【python】-- NameError: name 'reload' is not defined
- Python NameError: name 'reduce' is not defined
- python NameError: name ' book ' is not defined
- Eclipse 中web项目报 target runtime apache tomcat XX.XX is not defined.
- Hibernate XX is not Mapped问题笔记
- Ext is not defined
- $ is not defined error
- $ is not defined error
- dojo is not defined!
- RateLimiter限流
- mysql_insert 动态值设置表达式
- SpringBoot在利用JDBCTemplate连接数据库的时候报错Incorrect column count: expected 1, actual 3] with root cause
- SpringMVC+redis整合
- 周报总结
- 【个人笔记】python input() xx is not defined
- $.ajax同步请求
- HTTP协议【详解】——经典面试题
- linux下通过命令行更新android sdk
- c#数据结构--树
- phpstorm的部分设置及快捷键
- NFS原理详解
- 手把手教你如何优化MySQL数据库(二)
- ForkJoinTask任务框架简介