自己写代码遇到的小问题

def ppp():    print('***')a = 'ppp'

问:如何用字符串a调用ppp()?

a()是肯定不行的

此处使用eval() 可以将一行字符串转化为可执行代码

eval(a)()
output = ***

即可轻松解决