我无法导入模块“ msvcrt”

时间:2019-05-10 05:12:49

标签: python python-3.x msvcrt

每次运行此程序时,该错误都会显示在框中。

我使用Windows 10运行该程序。

import random
import msvcrt
a=random.randint(1,50)
while True:
    text=('put your guess here >>>')
    b=input(text)
    print(b)
    print(a)
    while True:
        pk=msvcrt.getch()
        b=input(text)
        if int(b)>a:
            print('too large')
        if int(b)<a:
            print('too small')
        if int(b)==a:
            print('correct, you guessed the number!')
            break
        if pk == 'r':
            a=random.randint(1,50)
            print`

Traceback (most recent call last): File "main.py", line 2, in <module> import msvcrt ImportError: No module named 'msvcrt'

我希望导入成功,但是没有成功。

0 个答案:

没有答案