这似乎是您要找的东西:
Choose_Item = eval(input("Select your item: "))但是,这可能不是最好的策略,因为错字或恶意用户很容易使您的代码崩溃,系统过载或执行他们喜欢的任何其他讨厌的事情。对于这种特殊情况,更好的方法可能是
items = {'item1': 'bill', 'item2': 'cows', 'item3': 'abcdef'}choice = input("Select your item: ")if choice in items: the_choice = items[choice]else: print("Uh oh, I don't know about that item")


