TypeError: int() argument must be a string, a bytes-like object or a number, not 'builtin_function_o

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_43283397/article/details/102696860
import random
print(int(random.random))

错误如下:
在这里插入图片描述
解决办法:
在其后加个括号

import random
print(int(random.random()))

结果为: 0

import random
print(random.random())

结果为:生成0-1之间的随机数

猜你喜欢

转载自blog.csdn.net/weixin_43283397/article/details/102696860