[ python ] input()和raw_input()

input() 传进来的参数是表达式,会运行的,raw_input()的参数只是字符串。

===============================
def test():
~a = 1
~b = 2
~c = input("input your number:")
~d = raw_input("input your number:")

test()
# 先后输入两次 a + b
# => 3
# => a + b
===============================

使用raw_input()会更安全。
原文地址:https://www.cnblogs.com/cly84920/p/4426730.html