random module error when run as .py

前端 未结 2 734
清歌不尽
清歌不尽 2021-01-15 23:34

It does not load the specific module of random when you run it as a .py. But if I load it in the python shell, I have no problems.

# -*- coding: utf-8 -*-
#         


        
相关标签:
2条回答
  • 2021-01-16 00:25

    Change the file name of your code to "myrandom.py". And then run the program.

    Update: Please don't name your Python source code file to standard modules. As it will cause error. Because right now instead of importing the standard library RANDOM of python, the python imports this random.py and which causes the error.

    e.g. Do not give your python source code following names etc.:

    1. random.py
    2. time.py
    3. csv.py
    4. etc... ... ... ....
    0 讨论(0)
  • 2021-01-16 00:40

    You can try re-naming the file and try again

    0 讨论(0)
提交回复
热议问题