您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

【Python报错】ComplexWarning: Casting complex values to real discards the imaginary part

5b51 2022/1/14 8:25:21 python 字数 2210 阅读 997 来源 www.jb51.cc/python

运行代码: importnumpyasnp np.seterr(all=\'warn\') A=np.array([10]) a=A[-1] a**a报错: ComplexWarning:Castingcomplexvaluestorealdiscardstheimaginarypart

概述

运行代码

报错:

ComplexWarning: Casting complex values to real discards the imaginary part

(将复数转换为实数丢弃虚部)

原因:

a是int32,能表示的最大数是2**32-1,而10**10显然超出这个范围;


原文地址:

https://stackoverflow.com/questions/7559595/python-runtimewarning-overflow-encountered-in-long-scalars

总结

以上是编程之家为你收集整理的【Python报错】ComplexWarning: Casting complex values to real discards the imaginary part全部内容,希望文章能够帮你解决【Python报错】ComplexWarning: Casting complex values to real discards the imaginary part所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶