0
How can I do to validate what the user enters by keyboard with Python?
7 odpowiedzi
+ 6
Are you talking about regular input with the input() function, or are you talking about detecting a key press (single key without input() function)?
+ 3
Maybe this way:
answer = input("y or n")
if answer == "y" :
some code
if answer == "n" :
some other code
+ 2
Ah, ok. I think Lothar will help.
And here is a Modul. Maybe this is what are you looking for
https://pypi.org/project/keyboard/
+ 2
Here you can find some helpful information. Be aware, that there can be problems with a platform independent solution.
https://stackoverflow.com/questions/24072790/detect-key-press-in-JUMP_LINK__&&__python__&&__JUMP_LINK
0
I am talking about detecting a keypress
0
You can import "os" module and use it to find users, then give them permission with "if/else"
For example my user is "Mehran" so I try this code:
```
import os
if os.getlogin() == "Mehran":
a = input()
else:
print("Permission denied!")
```
0
you must install keyboard module
if you'r on windows
python -m pip install keyboard
there is some methods in this module to find which keys pressed by user.
search this article in stackoverflow website to see what i'm sayin:
detect key press in python