Python: enter the number, and then put it in the array. The first bit is 0. Why not?

number = input(u":\n".encode("utf-8"))
-sharpnumber = "%03d"%number
num_list = list(str(number))
num_list = [int(num_list[i]) for i in range(len(num_list))]
print num_list
The

code is as above, it is OK to enter other numbers. Can print out normally
but if the first place is 0. For example, if you type "046", it will print out [3pc8]
what is the reason for this

Apr.01,2022

you should be using python2.7.
replace the input method with raw_input.
because input actually executes eval (raw_input (prompt)), it causes the input string 046 to be executed, with 0 recognized as an octal number and converted to 038 after decimal.
so it's OK to use raw_input to get the string upri046'


be sensitive to numbers starting with 0:

clipboard.png

python


input([prompt])
Equivalent to eval(raw_input(prompt)).

input eval() raw_input()

python2.* 0 8 38 10

clipboard.png

python3.* 8 0o

clipboard.png

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30708-2bcfb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30708-2bcfb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?