【问题标题】:SL4A import failsSL4A 导入失败
【发布时间】: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 sl4a


    【解决方案1】:

    尝试将您的脚本另存为 random.py 以外的其他内容。它可能是自己进口的。请删除 CWD 中的 random.py 旧副本,然后重试。

    【讨论】:

    • 重命名成功!我忘记了 Python 中的这种行为,谢谢。
    猜你喜欢
    • 1970-01-01
    • 2016-04-07
    • 2018-03-17
    • 2020-03-04
    • 2014-03-28
    • 2016-07-14
    • 2018-06-07
    • 2017-06-14
    • 2021-03-29
    相关资源
    最近更新 更多