我收到此错误:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 2
d = {0:00 , 1:11, 2:10, 3:09, 4:08, 5:07, 6:06, 7:05, 8:04, 9:03, 10:02, 11:01, 12:12}
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integer
这是我的代码:
x, y = map(int, input().split())
d = {0:00 , 1:11, 2:10, 3:09, 4:08, 5:07, 6:06, 7:05, 8:04, 9:03, 10:02, 11:01, 12:12}
print(d)
print(d[3])
在 Python 中,不能使用带前导零的整数,如
01
、001
对于您的情况,您可以使用这样的字符串
d = {0: '00', 1: '11', 2: '10', 3: '09', 4: '08', 5: '07', 6: '06', 7: '05', 8: '04', 9: '03', 10: '02', 11: '01', 12: '12'}
print(d)
print(d[3])