本文整理汇总了Python中simulation.Simulation.simulation方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.simulation方法的具体用法?Python Simulation.simulation怎么用?Python Simulation.simulation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation.Simulation
的用法示例。
在下文中一共展示了Simulation.simulation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import simulation [as 别名]
def main():
db = Database("zoo.db")
zoo = Zoo(50, 1000000000, db)
simulation = Simulation(zoo)
print("welcome to our zoo! enter help to get available commands")
while True:
commands = input("what'd you like to do? ").split(' ')
command = commands[0]
args = commands[1:]
if command == 'help':
print(instructions())
elif command == 'simulate':
try:
simulation.simulate(*args)
except AttributeError:
print('\n'.join(["wrong command or wrong arguments entered!",
"maybe enter help again :)"]))
elif command == 'exit':
print('bye')
exit(0)
else:
try:
print(zoo.__getattribute__(command)(*args))
except (TypeError, AttributeError):
print('\n'.join(["wrong command or wrong arguments entered!",
"maybe enter help again :)"]))
sm = Simulation(zoo)
sm.simulation('months', 2)