我应该使用scipy.pi,numpy.pi还是math.pi? [英] Should I use scipy.pi, numpy.pi, or math.pi?

查看:185
本文介绍了我应该使用scipy.pi,numpy.pi还是math.pi?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用SciPy和NumPy的项目中,我应该使用scipy.pinumpy.pi还是math.pi?

In a project using SciPy and NumPy, should I use scipy.pi, numpy.pi, or math.pi?

推荐答案

>>> import math
>>> import numpy as np
>>> import scipy
>>> math.pi == np.pi == scipy.pi
True

所以没关系,它们都是相同的值.

So it doesn't matter, they are all the same value.

所有三个模块都提供pi值的唯一原因是,如果仅使用三个模块之一,则可以方便地访问pi,而不必导入其他模块.他们没有为pi提供不同的值.

The only reason all three modules provide a pi value is so if you are using just one of the three modules, you can conveniently have access to pi without having to import another module. They're not providing different values for pi.

这篇关于我应该使用scipy.pi,numpy.pi还是math.pi?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆