求大佬帮我看看这段代码,为啥有if __name__ == main就打不出东西,没有就行
from typing import Listdef test1(nums:List,target):
#nums =
p = len(nums)
print(p)
for i in range(len(nums)):
for j in range(i+1,p):
if nums + nums == target:
flag1 = i
flag2 = j
break
break
return(flag1,flag2)
#w =
#h = 3
#if __name__ == 'main':
nums =
target = 3
print(test1(nums,target)) 很奇怪,没有这个if__name == main就是正常的,有就完全打不出东西 kking1 发表于 2022-5-14 11:14
很奇怪,没有这个if__name == main就是正常的,有就完全打不出东西
你的 main 也需要双下划线,参考代码:
from typing import List
def test1(nums:List,target):
#nums =
p = len(nums)
print(p)
for i in range(len(nums)):
for j in range(i+1,p):
if nums + nums == target:
flag1 = i
flag2 = j
break
break
return(flag1,flag2)
#w =
#h = 3
if __name__ == '__main__':
nums =
target = 3
print(test1(nums,target))
Twilight6 发表于 2022-5-14 11:15
你的 main 也需要双下划线,参考代码:
谢谢大佬,妈耶,眼睛看花了,没看到这个
页:
[1]