Python random function

前端 未结 9 1134
后悔当初
后悔当初 2020-12-10 03:26

I\'m having problems with Python\'s import random function. It seems that import random and from random import random are importing different thing

9条回答
  •  半阙折子戏
    2020-12-10 04:17

    You have to import the random function, from the random module before you can use it use it

    In [1]: from random import random
    
    In [2]: random()
    Out[2]: 0.5607917948041573
    

提交回复
热议问题