错题本

Posted lizhiqing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错题本相关的知识,希望对你有一定的参考价值。

报错信息:Cannot cast ufunc subtract output from dtype(‘float64‘) to dtype(‘int64‘) with casting rule ‘same_kind‘

输入的数据类型为浮点型,需要的数据类型是整形。

可以通过下面的语句完成类型转换

np.array(dta,dtype=np.float) 

 

AttributeError: ‘_io.TextIOWrapper‘ object has no attribute ‘xreadlines‘

  python 2 中有file.xreadlines(),作为一个迭代器,一次读取一行文件,在python3中已经移除,可使用file.readlines()代替

 

matrix 和 np.array 的逆

np.linalg.inv

matrix.I

  

以上是关于错题本的主要内容,如果未能解决你的问题,请参考以下文章