我不断地发现这个错误: 回溯(最近一次呼叫最后一次): 文件“/root/sandbox7723bf31/nt-test-68764d5e.py”,第2行,在 从testmyrange导入myRange ImportError:无法从“testmyrange”导入名称“myRange”(/root/sandbox7723bf31/testmyrange.py)
#define and test a function range with a main defined
#define myRange() method
def myRange(p, q == None and r == None):
if p == 0 and q == None and r == None:
return []
if r == None:
step = 1
else:
step = r
if q == None:
start = 0
stop = p
else:
start = p
stop = q
res = []
i = start
def main():
while True:
res.append(i)
if step > 0 and i + step >= stop:
break
elif step < 0 and i + step <= stop:
break
else:
i = i + step
return res
#call main and end program
if __name__ == "__main__" :
main()
对MyRange进行简单测试的代码
输出
相关问题 更多 >
编程相关推荐