[ 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()会更安全。
posted on 2010-07-16 16:25  真阿当  阅读(103)  评论(0编辑  收藏  举报