python 字符串数组互转


字符串转数组
str = '1,2,3'
arr = str.split(',')

数组转字符串
arr = ['a','b']
str = ','.join(arr)

arr = [1,2,3]

str = ','.join(str(i) for i in b)

二维数组转string:

anchors = centroids.copy()
widths = anchors[:, 0]
sorted_indices = np.argsort(widths)
for i in sorted_indices:
    out_string += str(int(anchors[i,0]*416)) + ',' + str(int(anchors[i,1]*416)) + ', '
        
print("old",out_string[:-2])

你可能感兴趣的:(python)