二、Python-----用户交互

1.用户交互

Python 3.0的写法

name = input("Please input your name:")

Python 2.0的写法

name = raw_input("Please input your name:")

Python2.7的写法

name = raw_input("Please input your name:")

=====================================

name = input("Please input your name:")

会提示NameError: name 'xxxxx' is not defined

这就说明了2.7中 的 input 输入的是什么格式就会被解释器当做什么格式

当你输入数字 就会被认为数字,当你输入的是变量(不加引号)就会被认为是变量,当你输入的是字符串(加引号)就会被认为是字符串.

所以在3.0中去烦从简 把raw_input取消了.

python2              Python3

input()--------------------------->>eval(input())

raw_input()----------------------->>input()

原文地址:https://www.cnblogs.com/nb-blog/p/5103976.html