当我试图将值转换为int时,我在python中遇到了这个错误。你知道吗
invalid literal for int() with base 10: '0,72367,72565,73005,73087,73113,73129,73313,73661,74049,74222,74350,74403,74501\n'
我要的不是这个
0,72367,72565,73005,73087,73113,73129,73313,73661,74049,74222,74350,74403,74501
存储在int的numpy数组中
我的密码是
f = open('points.txt')
# reading the lines of the file
line = f.readline()
while line:
points = np.array([], dtype=int)
#print("voxel", voxel_label, " : ", line)
points = np.append(points, line)
line = f.readline()
voxel_label += 1
当我把点转换成int时,它给了我一个错误。我想从文本文件中读取行,并将其作为int值放入numpy数组点中。你知道吗
points array(['0,1883,1965,2176,2236,2273,2502,2528,2542,2963,2979,3288,3519\n'],
dtype='<U62')
我想把这个'points'numpy数组转换成int类型。我不明白为什么结尾有。你知道吗
如何将“points”numpy转换为int
如果您的文件纯粹由逗号分隔的数字组成,则需要以下内容:
相关问题 更多 >
编程相关推荐