1. pass 什么都不做
name = 'zenos'
if name == 'zenos':
print(name)
========================1=========================
2. del 删除
scourdrel = {
'age': 42,
'frist name': 'Robin',
'last name': 'of Locksley'
}
robin = scourdrel
print(scourdrel)
print(robin)
scourdrel = None
print(scourdrel)
print(robin)
del robin
try:
print(robin)
except NameError as e:
print('[NameError]: ', e)
========================2=========================
{'age': 42, 'frist name': 'Robin', 'last name': 'of Locksley'}
{'age': 42, 'frist name': 'Robin', 'last name': 'of Locksley'}
None
{'age': 42, 'frist name': 'Robin', 'last name': 'of Locksley'}
[NameError]: name 'robin' is not defined
3. exec 将字符串作为代码执行
exec('print("hello world")')
========================3=========================
hello world
4. eval 计算并返回字符串表示的表达式结果
eval('print("hello world")')
========================4=========================
hello world