【发布时间】:2012-06-25 17:07:22
【问题描述】:
在 Python 终端,我可以运行:
import random
random.randint(1,6)
正如预期的那样,它给出了一个数字。但是,我将此脚本另存为 random.py 并无法运行:
import random
print random.randint(1,3)
它说“AttributeError:'module'对象没有属性'randint'”
【问题讨论】:
在 Python 终端,我可以运行:
import random
random.randint(1,6)
正如预期的那样,它给出了一个数字。但是,我将此脚本另存为 random.py 并无法运行:
import random
print random.randint(1,3)
它说“AttributeError:'module'对象没有属性'randint'”
【问题讨论】:
尝试将您的脚本另存为 random.py 以外的其他内容。它可能是自己进口的。请删除 CWD 中的 random.py 旧副本,然后重试。
【讨论】: