我想在def函数中存储每个Callout 例如:
def shooting():
print("bang bang")
def mugging():
print("money, now!")
callout = ['shooting', 'mugging']
randomthing = random.choice(callout)
print(randomthing + "()")
因此,每个callout都存储在def函数中。然后在callout和randomthing中随机化。然后(我知道这部分是错误的)我希望它调用mugging()或shooing(),但有50/50的机会。你知道吗
你差点就成功了!只需删除引号,并直接存储函数名。Python中的函数与变量类似:
相关问题 更多 >
编程相关推荐