python 函数参数不指定如何进行分配

# _*_ coding: utf-8 _*_
__author__ = 'pythonwu'
__date__ = "2018/5/21 0:07"

def interval(start,stop=None,step=1):
if stop is None:
start,stop=0,start #如果没有stop值,进行指定
result = []
i = start
print(i)
while i < stop:
result.append(i)
i += step
return result


print(interval(10))
print(interval(1,10))
print(interval(1,10,2))
posted @ 2018-05-27 23:44  五等码农  阅读(179)  评论(0编辑  收藏  举报