python - 无法使用 * with 导入
问题描述
我有以下代码:
https://github.com/marcomusy/vedo/blob/master/examples/basic/colorlines.py
"""Color lines by a scalar"""
from vedo import *
pts1 = [(sin(x/8), cos(x/8), x/5) for x in range(25)]
l1 = Line(pts1).c('black')
l2 = l1.clone().rotateZ(180).shift(1,0,0)
dist = mag(l1.points()-l2.points()) # make up some scalar values
# The trick here is to think that the "body" of a line is a cell
# so we can color cells as we do for any other polygonal mesh:
lines = Lines(l1, l2).lw(4).cmap('Accent', dist, on='cells')
lines.addScalarBar(title='distance') # or e.g.:
# lines.addScalarBar3D(title='distance').scalarbar.rotateX(90).pos(1,1,2)
show(l1,l2, lines, __doc__, axes=1, bg2='lightblue', viewup='z')
但是,这给了我以下错误:
Traceback (most recent call last):
File "vedo.py", line 2, in <module>
from vedo import *
File "/Users/prikshetsharma/Documents/clotorch/src/clotorch/flight/vedo.py", line 4, in <module>
pts1 = [(sin(x/8), cos(x/8), x/5) for x in range(25)]
File "/Users/prikshetsharma/Documents/clotorch/src/clotorch/flight/vedo.py", line 4, in <listcomp>
pts1 = [(sin(x/8), cos(x/8), x/5) for x in range(25)]
NameError: name 'sin' is not defined
但是sin是从vedo的init .py文件中的numpy导入的,所以应该在这个文件中定义。
解决方案
推荐阅读
- javascript - 使用 sort 和 reduce 功能对 Object 的对象进行排序
- java - 在sqlite android中存储布尔值
- java - 如何从日志中的日志请求中排除特定属性或数据类型?
- python - ansible docker-compose 模块,ansible 的结果与主机上的 ssh 不同
- c++ - CMake 错误找不到兼容的包“SDL2”的配置文件
- python - 需要相互导入组件的 Python 文件
- r - 将给定年份的组数与上一年的不同组进行比较
- vb.net - 使用 vb.net 从 word 文件中删除行
- jestjs - 用 Jest 模拟 Lerna 范围模块
- node.js - 如何制作一个不和谐的机器人来回复我发送的任何内容