![](/img/trans.png)
[英]AttributeError: 'numpy.ndarray' object has no attribute 'split'
[英]How to get rid of “numpy.ndarray” has no attribute split?
我嘗試編輯一個 stl 文件。 關於這一點,我使用 numpy-stl 閱讀了 stl 文件。 現在,當我嘗試拆分其中存在的行時,它向我顯示一個錯誤:
'numpy.ndarray' object 沒有屬性 'split'
如何克服這一點? 下面是代碼。
import numpy as np
import stl
from stl import mesh
lines = mesh.Mesh.from_file('mesh.stl')
count = 0
for line in lines:
if line.split()[0] == "solid":
repl = line.split()[1]
print(repl)
任何線索將不勝感激。
問候, Sunag R A。
這是因為您獲得了應用拆分的 ndarray object。
只需在執行之前將其轉換為字符串(使用tostring()方法),它就會起作用。
只需使用str(line)
代替tostring(line)
方法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.