安装完Numpy之后运行报错,提示这个,怎么解决
Traceback (most recent call last):
File "E:\Python\lib\code.py", line 91, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "E:\PyCharm 2021.3.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "E:\PyCharm 2021.3.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "E:/Code/learning/com/shi/tang/learningNumPy/learningNumPy.py", line 12, in <module>
array1 = np.arange([1, 2, 3, 4])
TypeError: unsupported operand type(s) for -: 'list' and 'int'
array1 = np.arange([1, 2, 3, 4])
这句写错了,要么应该是
array1 = np.array([1, 2, 3, 4])
要么应该是
array1 = np.arange(1, 5)
这两种写法都可以得到array([1, 2, 3, 4])