#coding=utf-8
__author__ = 'baodong'
inp = input("Please Input ...")
print(type(inp))
print(inp)
# >>>123
# <type 'int'>
# 123
# >>>3.14
# <type 'float'>
# 3.14
# >>>2 ** 10
# <type 'int'>
# 1024
# >>>abc
# Traceback (most recent call last):
# File "/Users/baodong/PycharmProjects/Learning/test0.py", line 4, in <module>
# inp = input("Please Input ...")
# File "<string>", line 1, in <module>
# NameError: name 'abc' is not defined
# >>>'abc'
# <type 'str'>
# abc
input()
接收表达式。字符串必须用引号包起来。
对数字有特殊处理。
Consider using the raw_input() function for general input from users.
#coding=utf-8
__author__ = 'baodong'
inp = raw_input("Please Input ...")
print(type(inp))
print(inp)
# >>>123
# <type 'str'>
# 123
# >>>3.14
# <type 'str'>
# 3.14
# >>>1+3
# <type 'str'>
# 1+3
# >>>abc
# <type 'str'>
# abc
raw_input()
“生input”
读一行并以string输出,不对表达式处理,字符串不需要引号。