[基础] - Python中 raw_input 和 input 的区别
2015-11-25 14:17
495 查看
[基础] - Python中 raw_input 和 input 的区别
raw_input不管用户输入什么类型的都会转变成字符串型。
input
根据用户输入变换相应的类型,如果要输入字符和字符串的时候必须要用引号包起来。
>>> raw_input_A = raw_input("raw_input: ") raw_input: abc >>> input_A = input("Input: ") Input: abc Traceback (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" >>> >>> raw_input_B = raw_input("raw_input: ") raw_input: 123 >>> type(raw_input_B) <type 'str'> >>> input_B = input("input: ") input: 123 >>> type(input_B) <type 'int'>
4000
相关文章推荐
- 【Python】django表单与提交
- python 看到的用法的记录
- python进行crc校验的方法小感
- Python数据分析扩展库
- python20151125
- 每天一点python——xlrd
- Python面向对象关系
- 实现MySQL回滚的Python脚本的编写教程
- pickle 在python 2和python 3中兼容性问题
- 多线程学习——python脚本批量修改华为交换机端口配置
- python绘图工具reportlab介绍----续
- python基础知识小结之集合
- Python - 操作Excel(中)
- Beginning Python Chapter1
- python 多线程实现检测服务器在线情况
- python 查看API
- python的文件句柄一次只能用一次
- python 采集MySQL数据,并更新到另外一个库
- Python 批量下载文件
- 如何利用cURL和python对服务端和web端进行接口测试