raw_input与input

python2.7版本中等待用户输入内容的函数是raw_input

1 a = raw_input(">>>")
2 print a

“>>>”为提示信息,我随便写了一个,运行并输入hello world

输出结果:

>>>hello world
hello world

python3.5版本中等待用户输入内容的函数是input,3.5版本中移除了raw_input这个函数

a = input(">>>")
print a

操作过程与2.7版本无异

PS:输入时的提示信息也可以使用变量来代替,例如:

1 prompt = ">>>"
2 a = raw_input(prompt)
3 print a
原文地址:https://www.cnblogs.com/zhangzengqiang/p/7481712.html