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

后端 未结 4 746
悲&欢浪女
悲&欢浪女 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:47

    The solution to your problem is renaming your file (random.py) to something other than Python built-ins, standard libraries, reserved keywords etc.

    However I strongly recommend you take Python Tutorial, before trying any other tutorial or book. You especially need to learn more about Python scopes and namespaces.

提交回复
热议问题