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基础,列表转字符串,字符串转列表,字符串与列表互转,python中数组,列表转字符串方法大全)