属性错误

时间:2013-12-04 15:59:31

标签: python attributeerror

我打开了一个命令提示符,看看为什么这段代码不起作用,它说:

AttributeError:'module'objec没有属性'randint'

import random

print('I am thinking of a number between 1 and 50')

number = random.randint(1, 50)
guess = int(input('Can you guess what it is: '))

while guess != number:
    if guess > number:
        print('Lower...')

    else:
        print('higher...')

    guess = int(input('Can you guess what it is: '))


print('Correct!')

input('\n\nEnter.')

1 个答案:

答案 0 :(得分:2)

您在当前目录中有一个名为random.py的脚本(可能是此脚本)。将其重命名为其他内容,因为它会影响标准import random