Why this python program is not working? AttributeError: 'module' object has no attribute

后端 未结 4 750
悲&欢浪女
悲&欢浪女 2020-12-11 03:13

I wrote a very simple python program.

#!/usr/bin/env python
import random
x = random.uniform(-1, 1)
print str(x)

I run this from command pr

4条回答
  •  一向
    一向 (楼主)
    2020-12-11 03:32

    Don't name your program as an Library. And just as a Tip: You don't need an String storing something and printing it out just after generating it.

    #!/usr/bin/env python
    import random
    print(random.uniform(-1, 1))
    

    This will work fine too ;)

提交回复
热议问题