raw_input() 与 input() __ Python
来源:互联网 发布:数据透视表怎么做差异 编辑:程序博客网 时间:2024/06/05 08:55
raw_input() 与 input() __ Python这两个函数均能接收字符串,但 raw_input() 直接读取控制台的输入(任何类型的输入它都可以接收)。而对于 input() ,它希望能够读取一个合法的 python 表达式,即你输入字符串的时候必须使用引号将它括起来,否则它会引发一个 SyntaxError 。
raw_input()将所有输入作为字符串看待,返回字符串类型。而 input() 在对待纯数字输入时具有自己的特性,它返回所输入的数字的类型(int, float);input() 可接受合法的 python 表达式,举例:input( 1 + 3 ) 会返回 int 型的 4 。
>>> raw_input_A = raw_input("raw_input: ")raw_input: abc >>> input_A = input("Input: ")Input: abcTraceback (most recent call last): File "<pyshell#1>", line 1, in <module> input_A = input("Input: ") File "<string>", line 1, in <module>NameError: name 'abc' is not defined >>> input_A = input("Input: ")Input: "abc" >>>
阅读全文
1 0
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python
- [python][转]raw_input() 与 input() __ Python
- raw_input() 与 input() __ Python 的区别
- raw_input() 与 input() __ Python 【转】
- Socket粘包问题
- 服务器性能监控---工具篇
- 关于指纹硬件ID脚gpio兼容原理推导
- 三种出错处理方式各自优缺点
- Nginx超完整配置技术说明
- raw_input() 与 input() __ Python
- C++Primer Plus(第六版) 第八章 第二题
- Cygwin Android源代码下载
- android中的下拉刷新
- 一个普通的十年
- c语言范式编程入门二
- 深入理解Spark 2.1 Core (一):RDD的原理与源码分析
- 第6章 目录与文件
- linux初级命令