简体   繁体   中英

Key Press To Print Words (For Python)

Im lookting to see if its possible to print text with the press of a button, For example

Print("Text Here") if Press (key)

Im using this to make the introduction to my program more interactive. Thank you

Yes, by using the OS module.

Windows:

import os
os.system('pause>nul')
print("Hello")

Bash, (Linux):

import os
os.system('read -n1 -r -p Press any key to continue')
print("Hi")

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