Python缺少很多模块

时间:2017-11-29 17:47:12

标签: python python-3.x

我刚刚开始学习python3并想制作一个返回5个随机整数值的简单程序,所以我试过了:

import random

for i in range(5):
    x=random.randint(1,6)
    print (x)

(编辑:我将文件名更改为tyxaios.py并收到以下错误)

Traceback (most recent call last):
  File "tyxaios.py", line 1, in <module>
    import random 
  File "/home/drunkbanana/Documents/python/random.py", line 4, in <module>
    x=random.randint(1,6)
AttributeError: module 'random' has no attribute 'randint'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in <module>
    import subprocess, tempfile, os.path, re, pwd, grp, os, time
  File "/usr/lib/python3.5/tempfile.py", line 184, in <module>
    from random import Random as _Random
  File "/home/drunkbanana/Documents/python/random.py", line 4, in <module>
    x=random.randint(1,6)
AttributeError: module 'random' has no attribute 'randint'

Original exception was:
Traceback (most recent call last):
  File "tyxaios.py", line 1, in <module>
    import random 
  File "/home/drunkbanana/Documents/python/random.py", line 4, in <module>
    x=random.randint(1,6)
AttributeError: module 'random' has no attribute 'randint'

我已经在我的电脑上安装了pip(Ubuntu 16.04 LTS)并尝试了pip install random但它不起作用。当我尝试使用smptlib库和datetime时,我遇到了类似的错误。

我该怎么办?

0 个答案:

没有答案
相关问题