I know this is too late but for those who are coming here for the first time, I'd like to post a solution. I have a float value index
and a string imgfile
and I had the same problem as you. This is how I fixed the issue
index = 1.0
imgfile = 'data/2.jpg'
out = '%.1f,%s' % (index,imgfile)
print out
The output is
1.0,data/2.jpg
You may modify this formatting example as per your convenience.