python: input()、raw_input() 探究
来源:互联网 发布:淘宝押金1000怎么上交 编辑:程序博客网 时间:2024/06/11 06:22
实验
a = input('请输入:')print a
如果输入字符串,则马上报错:
请输入:str Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<string>", line 1, in <module>
但是如果输入整数,却不会报错:
请输入:1010
如果把 input
改成 raw_input
,则可以正常记录键盘输入的字符串:
a = raw_input('请输入:')print a
请输入:strstr
原因
原因就在于,input
只能接受整型输入:
a = input('请输入:')print type(a)
请输入:10<type 'int'>
而 raw_input
可以接受字符串输入:
a = raw_input('请输入:')print type(a)
请输入:str<type 'str'>
阅读全文
1 0
- python: input()、raw_input() 探究
- Python input() pk raw_input()
- 【python】raw_input() 和input()
- Python raw_input() 和input()
- python输入输出---input,raw_input
- Python raw_input() vs input()
- python input()与raw_input()
- [Python] input() vs raw_input()
- raw_input() 与 input() Python
- Python input和raw_input
- python input()与raw_input()
- python:input()和raw_input()
- python input,raw_input函数
- python input()与raw_input()
- python input() 与raw_input()
- raw_input() 与 input() __ Python
- Python:raw_input 和 input用法
- raw_input() 与 input() __ Python
- 自定义控件之下拉刷新列表
- TensorFlow Wide And Deep 模型详解与应用 TensorFlow Wide-And-Deep 阅读344 作者简介:汪剑,现在在出门问问负责推荐与个性化。曾在微软雅虎工作,
- SCI 投稿Cover letter模板大全 (2012-01-12 16:20:30)转载▼ 标签: e-mail 稿号 意见 修改稿 信件 杂谈分类: technology 1.第一次投稿Cov
- Mybatis的功能之一:数据库表自动生成对应的model类,dao接口和Mapper.xml文件
- 462. Minimum Moves to Equal Array Elements II
- python: input()、raw_input() 探究
- 新人报道,占个坑
- ORB-SLAM:文献阅读笔记
- Curl 示例
- 如何用命令行查IP?
- java学习思维导图
- Java常见面试(12)
- 矩阵快速幂(二分)
- 明明的随机数(2006年NOIP全国联赛普及组)