[英]Directing a user to different scripts from a menu script using inputs?
We have to make a program using Python for a college unit and I'm making one that you can use with Twitter. 我们必须为大学单位使用Python编写一个程序,而我正在编写一个可以与Twitter一起使用的程序。 I've done the scripts for posting tweets and viewing them but I want to make it so you can select different options from a sort of menu script and run the scripts from there?
我已经完成了用于发布推文和查看推文的脚本,但是我想这样做,以便您可以从某种菜单脚本中选择不同的选项并从那里运行脚本?
Example: 例:
Choose one: 1 选择一个:1
Enter tweet: 输入推文:
That sort of thing... Really confused! 那样的事情...真的很困惑!
If you want to display a text menu like that, use something like this (if using Python 3): 如果要显示这样的文本菜单,请使用以下命令(如果使用Python 3):
while True:
print("1. New tweet")
print("2. View tweets")
option = input("Choose one: ")
if option == "1":
# New tweet
elif option == "2":
# View tweets
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.