Python raw_input和input总结 在版本2和版本3中的区别
Python 2.3.4 (#1, Feb 2 2005, 11:44:13)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> user=raw_input("please input:")
please input:wei # raw_input 输入 字符串 成功
>>> user
'wei'
>>> user=input("please input:")
please input:123 # input 输入 数字 成功(返回的是数字)
>>> user
123
>>> user=raw_input("please input:")
please input:111 <span style="white-space:pre"> </span> # raw_input 输入 数字 成功(返回的还是当成字符串)
>>> user
'111'
>>> user=input("please input:")
please input:wei # input 输入字符串 失败
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<string>", line 0, in ?
NameError: name 'wei' is not defined
Python 2.7.3 同上
===================================================================================================================================
在Python 3.2.3中 input和raw_input 整合了,没有了raw_input
Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> user=raw_input("please input:") #没有了raw_input
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'raw_input' is not defined
>>> user=input("please input:")
please input:wei
>>> user
'wei'
>>> user=input("please input:") #input的输出结果都是作为字符串
please input:123
>>> user
'123'
Python raw_input和input总结 在版本2和版本3中的区别的更多相关文章
- raw_input() 与 input() __ Python
这两个均是 python 的内建函数,通过读取控制台的输入与用户实现交互.但他们的功能不尽相同.举两个小例子. 1 >>> raw_input_A = raw_input(" ...
- python中raw_input() 与 input()
参考网址:http://www.cnblogs.com/way_testlife/archive/2011/03/29/1999283.html 在python中如何接收一个输入的字符串. 举个例子: ...
- python中raw_input()与input()
raw_input([prompt]) input([prompt]) # prompt:如果参数存在,直接输出到屏幕上,不会再另起一行 raw_input 如其字面意思一样,返回输入字符的字符串形式 ...
- Python中的raw_input()和input()
raw_input()和input()都是python中的内建函数,用于读取控制台用户的输入,但有所区别: [nr@localhost conf]$ python Python 2.7.5 (defa ...
- Python:raw_input 和 input用法
转自:http://blog.csdn.net/kjing/article/details/7450146 Python input和raw_input的区别 使用input和raw_input都可以 ...
- Python 内置函数raw_input()和input()用法和区别
我们知道python接受输入的raw_input()和input() ,在python3 输入raw_input() 去掉乐,只要用input() 输入,input 可以接收一个Python表达式作为 ...
- raw_input() 与 input()
这两个均是 python 的内建函数,通过读取控制台的输入与用户实现交互.但他们的功能不尽相同. >>> raw_input_A = raw_input("raw_inpu ...
- raw_input() 与 input()的区别
raw_input和input两个均是 python 的内建函数,通过读取控制台的输入与用户实现交互.但他们的功能不尽相同.下面举两个例子,来说明两者 raw_input和input两个均是 pyth ...
- python里的input
python2和python3的input是不同的 python3的input 对于python3,只有input,官方文档里是这样描述的 def input(*args, **kwargs): # ...
随机推荐
- double 和 im2double 的区别
double 就是简单地把一个变量类型转换成double型,数值大小不变. 函数im2double将输入换成double类型.如果输入是unit8,unit16或者是二值的logical类型,则函数i ...
- 题解 P2026 【求一次函数解析式】
高中方式轻松解决这个模拟题. 首先我们了解斜率的简单求法: \[k= {y2-y1 \over x2-x1}{=}{\Delta y \over \Delta x}\] 然后我们了解到让我们求解一次函 ...
- Java并发编程:线程池
一.为什么使用线程池 使用线程的时候直接就去创建一个线程,这样实现起来非常简便,但是就会有一个问题: 如果并发的线程数量很多,并且每个线程都是执行一个时间很短的任务就结束了,这样频繁创建线程就会大大降 ...
- Callable 和 Runnable 的区别
Callable 和 Runnable 的使用方法大同小异, 区别在于: 1.Callable 使用 call() 方法, Runnable 使用 run() 方法 2.call() 可以返回值, 而 ...
- excel 技能收集
排序: 对某D列第4行开始的数据排序,对D4之后的700个数据全部排序 =RANK(D4,$D$4:$D$700)
- 【spoj SUBST1】 New Distinct Substrings
http://www.spoj.com/problems/SUBST1/ (题目链接) 题意 求字符串的不相同的子串个数 Solution 后缀数组论文题. 每个子串一定是某个后缀的前缀,那么原问题等 ...
- 关于Powershell对抗安全软件(转)
Windows PowerShell的强大,并且内置,在渗透过程中,也让渗透变得更加有趣.而安全软件的对抗查杀也逐渐开始针对powershell的一切行为.在https://technet.micro ...
- WEB入门.六 盒子模型
学习内容 CSS盒子模型 盒子之间的关系 页面元素定位 能力目标 理解盒子模型 理解内容与表现分离的优点 理解并掌握盒子之间的关系 理解并掌握绝对定位与相对定位的用法 本章简介 上一章节中已经讲解了页 ...
- java线程池赏析
1.线程池的顶级接口(Executor) 线程池的顶级接口(jdk > 1.5).仅仅定义了方法execute(Runnable). 该方法接收一个Runnable实例,用来执行一个任务,该任务 ...
- 解题:POI 2011 Strongbox
首先洛谷的题面十分的劝退(至少对我这个菜鸡来说是这样),我来解释一下(原来的英文题面): 有一个有若干个密码(每个密码都可以开箱子)的密码箱,密码是在$0$到$n-1$的数中的,且所有的密码都满足一个 ...