我想将浮点数向量写入字符串。我的部分代码是:
str_to_print = """
Tracking_ROI_X = %s
Tracking_ROI_Y = %s
"""
ROI_X_vect = [1272.0, 8.0, 8.0, 1272.0]
ROI_Y_vect = [1016.0, 1016.0, 8.0, 8.0]
str_to_print = str_to_print %(','.join(str(j) for j in ROI_X_vect))
str_to_print = str_to_print %(','.join(str(j) for j in ROI_Y_vect))
% OUTPUT, should be:
Tracking_ROI_X = [1272.0, 8.0, 8.0, 1272.0]
Tracking_ROI_Y_vect = [1016.0, 1016.0, 8.0, 8.0]
我收到一个名为 TypeError 的错误,但我不明白为什么?有什么解决办法呢?