简体   繁体   中英

How can I ask for user input in python through the terminal in windows?

I was trying to create my own version of the Jarvis terminal program that's on GitHub. I would prompt a menu for the user to see and choose from in the windows terminal and simultaneously keep calling functions given the input from the terminal. I know how to call files in the same dir with "import", but how would I pass the arguments the user gives me because as soon as I run my main program the code won't stop to ask the user for input.
An example would be
1. Time
2. Weather
3. Timer

file1 has the time function, file2 has weather, and file3 has a timer.

I would call file1, file2, and file3 in my main program, Assistant. File2 (Weather) expects the user to write a location and pass it to the function, for example, the user is supposed to write "Weather Dallas", and my code would give the weather in Dallas right now. But the problem is I don't know to keep asking for input in the terminal. I have used sys.argv in my programs but whenever I run my Assistant function, it just skips the user inputs.

您可以通过variable = input("Type something: ")获取输入

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM