关于input和raw_input的区别

#! /usr/bin/python
# -*- coding=UTF-8 -*-

a=input("name is :")
#此处如果输入 test,则报错,无法识别变量test;如果输入12,报错int
#如果此处输入的是"test"或者"12"或str(12),则正常
print "hello " + a + "!"

a=raw_input("name is :")
#此处输入test或12,正常

print "hello " + a + "!"

猜你喜欢

转载自blog.csdn.net/fristars2/article/details/75578329
今日推荐