convert number to string in python

后端 未结 5 1551
你的背包
你的背包 2021-01-26 17:40

I meet a problem about converting number to string.

I want to get a string \"0100\" from str(0100), but what I got is \"64\". Does any way I can do to get a string \"010

5条回答
  •  执念已碎
    2021-01-26 17:57

    The integer should be written as 100, not 0100.

    You can format the string with leading zeros like this:

    >>> "%04d" % 100
    '0100'
    

提交回复
热议问题