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中的区别的更多相关文章

  1. raw_input() 与 input() __ Python

    这两个均是 python 的内建函数,通过读取控制台的输入与用户实现交互.但他们的功能不尽相同.举两个小例子. 1 >>> raw_input_A = raw_input(" ...

  2. python中raw_input() 与 input()

    参考网址:http://www.cnblogs.com/way_testlife/archive/2011/03/29/1999283.html 在python中如何接收一个输入的字符串. 举个例子: ...

  3. python中raw_input()与input()

    raw_input([prompt]) input([prompt]) # prompt:如果参数存在,直接输出到屏幕上,不会再另起一行 raw_input 如其字面意思一样,返回输入字符的字符串形式 ...

  4. Python中的raw_input()和input()

    raw_input()和input()都是python中的内建函数,用于读取控制台用户的输入,但有所区别: [nr@localhost conf]$ python Python 2.7.5 (defa ...

  5. Python:raw_input 和 input用法

    转自:http://blog.csdn.net/kjing/article/details/7450146 Python input和raw_input的区别 使用input和raw_input都可以 ...

  6. Python 内置函数raw_input()和input()用法和区别

    我们知道python接受输入的raw_input()和input() ,在python3 输入raw_input() 去掉乐,只要用input() 输入,input 可以接收一个Python表达式作为 ...

  7. raw_input() 与 input()

    这两个均是 python 的内建函数,通过读取控制台的输入与用户实现交互.但他们的功能不尽相同. >>> raw_input_A = raw_input("raw_inpu ...

  8. raw_input() 与 input()的区别

    raw_input和input两个均是 python 的内建函数,通过读取控制台的输入与用户实现交互.但他们的功能不尽相同.下面举两个例子,来说明两者 raw_input和input两个均是 pyth ...

  9. python里的input

    python2和python3的input是不同的 python3的input 对于python3,只有input,官方文档里是这样描述的 def input(*args, **kwargs): # ...

随机推荐

  1. jion()说明

    转自:http://www.cnblogs.com/skywang12345/p/3479275.html jion(),只有当子线程执行完了,主线程才会执行 1. join()介绍 join() 定 ...

  2. SPOJ_VLATTICE

    题目是给你一个空间,和一个点(n,n,n),求从原点出发能够直接接触多少个点(不经过任何一个点)? 典型的mobius反演即可. 首先,ans=3,因为(1,0,0),(0,1,0),(0,0,1)这 ...

  3. Barricade HDU - 5889(最短路+最小割)

    Barricade Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  4. PowerDesigner在生成SQL时报错Generation aborted due to errors detected during the verification of the mod

    一.本章节要用到  ODBC连接数据库直接创建表,请先创建连接库的ODBC 请参考  新建  http://www.cnblogs.com/wdw31210/p/7580286.html 二.生成 去 ...

  5. 一些说明&其他奇奇怪怪的东西

    NOIP考完了,这篇博客彻底咕了.

  6. 51nod 1589 移数博弈 | 基数排序(ノಠ益ಠ)ノ彡┻━┻

    51nod 1589 移数博弈 题面 给出一个序列a,长度 n <= 10^7, a[i] <= 10^7 求每个长度 >= 2 的区间的最大值*次大值 之和. 题解 主要思路是求每 ...

  7. Android源码批量下载及导入到Eclipse

    1.去http://code.google.com/p/msysgit/downloads/list  下载Git,进行安装 2.生成批量下载脚本文件  下载批量工具CreatAutoGetSh(工具 ...

  8. k-Nearest Neighbor algorithm 思想

    转载      KNN--K最邻近算法思想 KNN算法的决策过程 k-Nearest Neighbor algorithm  上图中,绿色圆要被决定赋予哪个类,是红色三角形还是蓝色四方形?如果K=3, ...

  9. sqlalchemy基本使用

    一.ORM介绍 orm英文全称object relational mapping,就是对象映射关系程序,简单来说我们类似python这种面向对象的程序来说一切皆对象,但是我们使用的数据库却都是关系型的 ...

  10. Python【操作Redis数据库】

    Redis非关系型数据库,数据存放在计算机内存中,无SQL语句.Redis中有多种数据类型,比较常用的数据类型是string类型和hash类型.平时我们使用RedisDesktopManager来对R ...