سؤال

I would like to display a score with 7 digits. I tried to use string.format() in vain.

I have a score module and want to display like this : 0000000

My module add 10 points each time, so it has to be : 0000010 - 0000020 etc...

Any suggestion ?

هل كانت مفيدة؟

المحلول

Try this:

print(string.format("%07d", 10))

Output: 0000010

07 in the format specifier means use at least 7 digits, and fills them with leading 0s.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top