擅长:python、mysql、java
<p>如果您知道它总是以p开头(以结尾),可以这样做:</p>
<pre><code>for line in file:
coords = [float(c) for c in line.strip()[2:-1].split(',')]
mesh.verts.append(Blender.NMesh.Vert(*coords))
</code></pre>
<p>行[2:-1]是切片表示法,它跳过前2个字符和最后一个字符(这样<code>"(p(x,y,z)"</code>变成{<cd2>})。然后,它被split()得到一个字符串数组<code>["x", "y", "z"]</code>。然后,“对于数组中的每个坐标,给我一个浮点(坐标)”将是“float(c)for c in line…”的英文翻译</p>