if else print时引号特别重要,否则将会报错 NameError: name ‘nothing’ is not defined
sites = {'Google', 'Taobao', 'Runoob', 'Facebook', 'Zhihu', 'Baidu'}
if 'aobao' in sites:
print('something')
else:
print('nothing')
#记得这块的' '引号特别重要,
#否则将会报错 NameError: name 'nothing' is not defined
nothing
记得这块的’ ‘引号特别重要,
否则将会报错 NameError: name ‘nothing’ is not defined
这么说的原因是,
print()可以输出的内容有不同的数据类型,加’ '引号等于说明要输出字符串;
另外print()还可以输出赋值等等。