1
我試圖用犀牛Python來執行代碼和我有以下類型錯誤的一些問題:犀牛:不是所有的參數轉換期間字符串格式化
Message: not all arguments converted during string formatting
我寫的意思的代碼讀取點座標從文件「newpoints.csv」,並將它們用作Rhino Python的'AddLine'函數的參數。
#!/usr/bin/env python
import rhinoscriptsyntax as rs
file = open("C:\\Users\\Seshane Mahlo\\Documents\\MSc Thesis\\newpoints.csv", "r")
lines = file.readlines()
file.close()
ab = len(lines)
seq = range(0, ab-1, 2)
coordinates = []
startvals = []
stopvals = []
for line in lines:
coords = line.split(',')
xcoord = float(coords[0])
ycoord = float(coords[1])
point = (xcoord, ycoord)
coordinates.append(point)
starts = range(0, ab-2, 2)
ends = range(1, ab+1, 2)
for i,j in zip(starts, ends):
strt = coordinates[i]
stp = coordinates[j]
rs.AddLine(start=strt,end=stp)
如果可以,請爲錯誤消息提供更多上下文。目前還不清楚你的代碼是從給定的信息中拋出這個TypeError的。 –
@GordonWorleyIII錯誤似乎是由第27行跟蹤引起的: 第348行,在coerce3dpoint中,「C:\ Users \ Seshane Mahlo \ AppData \ Roaming \ McNeel \ Rhinoceros \ 5.0 \ Plug-ins \ IronPython(814d908a-e25c- 493d-97e9-ee3861957f49)\ settings \ lib \ rhinoscript \ utility.py「 line 310,in AddLine,」C:\ Users \ Seshane Mahlo \ AppData \ Roaming \ McNeel \ Rhinoceros \ 5.0 \ Plug-ins \ IronPython(814d908a -e25c-493d-97e9-ee3861957f49)\ settings \ lib \ rhinoscript \ curve.py「 line 27,in,」C:\ Users \ Seshane Mahlo \ AppData \ Roaming \ McNeel \ Rhinoceros \ 5.0 \ scripts \ drawlines。 PY」 –