python - 在python中计算长数字时出错
问题描述
我正在尝试计算一些大数的平方根,例如:
np.sqrt(324524513452345134623454326)
但我收到以下错误:
>>> import numpy as np
>>> np.sqrt(324524513452345134623454326)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute 'sqrt'
>>> np
<module 'numpy' from '/.../site-packages/numpy/__init__.py'>
>>> np.sqrt(324524)
569.6700799585669
注意:np
不是整数,它仍然绑定到numpy
模块!对于较小的整数,函数调用工作得很好。
我正在使用 python 3.6。
解决方案
推荐阅读
- python - 在 Python 的 netCDF4 中使用 scale_factor 和 add_offset 的示例?
- css - Wordpress 自定义样式编辑器
- reactjs - 带有 socket.io 状态的 UseEffect 钩子在套接字处理程序中不是持久的
- angular - 通过服务从一个组件获取数据到另一个组件并在 html 组件中呈现
- mongodb - MongoDB find() 查询
- typescript - TypeScript 构造函数批量赋值
- oracle - 了解oracle转换函数
- python - 从 Amazon S3、AWS CLI 或 Boto3 下载?
- java - 带有语言环境的 xhtml java 日历
- azure - Kubernetes入口重写问题