visual studio调用cmath库失败

rongyihit 2019-07-26 04:05:26
请教各位高手,在电脑上安装了anaconda,ide是visual studio,编译环境设置为anaconda。在代码中import cmath库,但是在代码里调用cmath.num_sqrt函数时报错,module 'cmath' has no attribute 'num_sqrt',看网上说是这个库没有安装上,但我在命令提示符里查了下,这个库是装了的,不知道为什么还会报错,求指导,先谢过了。
...全文
353 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
rongyihit 2019-07-26
  • 打赏
  • 举报
回复
引用 2 楼 黄哥Python培训 的回复:
cmath 是标准库,本来就没有num_sqrt方法或者属性。 ['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atanh', 'cos', 'cosh', 'e', 'exp', 'inf', 'infj', 'isclose', 'isfinite', 'isinf', 'isnan', 'log', 'log10', 'nan', 'nanj', 'phase', 'pi', 'polar', 'rect', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau']
哦对,把函数名更改了下,调通了,谢谢!
黄哥Python培训 2019-07-26
  • 打赏
  • 举报
回复
cmath 是标准库,本来就没有num_sqrt 用print(dir(cmath)) 输出下面的结果 ['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atanh', 'cos', 'cosh', 'e', 'exp', 'inf', 'infj', 'isclose', 'isfinite', 'isinf', 'isnan', 'log', 'log10', 'nan', 'nanj', 'phase', 'pi', 'polar', 'rect', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau'] 你能提供全部代吗? 有全部代码和完整报错信息,才好判断你遇到的问题。
黄哥Python培训 2019-07-26
  • 打赏
  • 举报
回复
cmath 是标准库,本来就没有num_sqrt方法或者属性。 ['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atanh', 'cos', 'cosh', 'e', 'exp', 'inf', 'infj', 'isclose', 'isfinite', 'isinf', 'isnan', 'log', 'log10', 'nan', 'nanj', 'phase', 'pi', 'polar', 'rect', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau']
一笑程序猴 2019-07-26
  • 打赏
  • 举报
回复
cmath.num_sqrt()

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧