python学习遇到很多错误,总是感觉莫名其妙,写下来,当做提示。
首先按照教程练习:
import numpy
a =random.rand(4,4)
print(a)
然后报错NameError: name 'random' is not defined
那我就定义上吧
import numpy
import random
a =random.rand(4,4)
print(a)
继续报错AttributeError: module 'random' has no attribute 'rand'
很无奈,上网百度了很久终于知道是怎么回事了,代码改成下面这样
import
numpy as np
print (a)