代码报错
def print_hello(name, sex):
sex_dict = {1: u'先生', 2: u'女士'}
print 'hello %s %s, welcome to python world!' %(name, sex_dict.get(sex, u'先生'))
print_hello('tanggu', 1)
老铁看看我这段代码执行不了呢,一直报错,无效语句。
你如果用的python3.x版本,那么 print是一个函数,要这样用
def print_hello(name, sex):
sex_dict = {1: u'先生', 2: u'女士'}
print ('hello %s %s, welcome to python world!' %(name, sex_dict.get(sex, u'先生')))
print_hello('tanggu', 1)
页:
[1]