更新时间:2021-11-23 19:01:34
由于'1' != 1
以及['1','2'] != [1,2]
如果您希望它正常工作,请尝试:
The code does not work because '1' != 1
and, consequently, ['1','2'] != [1,2]
If you want it to work, try:
a=[['1','2'],['1','3']]
for i in range(3):
for j in range(3):
if [str(i), str(j)] in a: # Note str
print a
(但是使用in
或如上所述的集合更好)
(But using in
or sets as already mentioned is better)