%d by python and addition ValueError: unsupported format character 'O' (0x4f) at index 2
i wrote a small function to do this job
x = 'INV-%05d'
m = x %(100+1)
i should have m = INV-0101
but i receive this error
ValueEr开发者_StackOverflow中文版ror: unsupported format character 'O' (0x4f) at index 2
this works without any problem, but i want to use an external variable
m = INV-%05d %(100+1)
-> m = INV-0101
because the original value should come from a saved variable
0x4f
, as reported in the error message, is the ASCII value for the capital letter O. It looks like you have made a typographical error, and put an O in when you want a zero.
精彩评论