开发者

%d by python and addition ValueError: unsupported format character 'O' (0x4f) at index 2

开发者 https://www.devze.com 2023-04-04 20:31 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消