0

I am working on a python project and I have got the following questions. How to catch a character in python ? What modules I need to use ? What functions I need to use?

psofoklis11
  • 37
  • 1
  • 6

1 Answers1

1

If you need to take a line of input just use:

x = input('Your name: ')
y = input()

Or (For Python 2)

x = raw_input('Your name: ')
y = raw_input()

For taking just one character from the keyboard you can use msvcrt.getch():

import msvcrt

key = msvcrt.getch()

if key == 'a':
    print("You pressed a")
Ciprum
  • 734
  • 1
  • 11
  • 18