4个回答
展开全部
def cycle(num): #产生某一数字的所有循环数
strNum = str(num)
length = len(strNum)
cycle_all = []
for i in range(length):
number = int(strNum[i:] + strNum[:i])
cycle_all.append(number)
return cycle_all
if __name__ == '__main__':
for i in cycle(1234):
print i,
展开全部
def cycle_list(num):
s=str(num)
return [int(s[i:]+s[:i]) for i in range(len(s))]
cycle_list(1234567)
#[1234567, 2345671, 3456712, 4567123, 5671234, 6712345, 7123456]
s=str(num)
return [int(s[i:]+s[:i]) for i in range(len(s))]
cycle_list(1234567)
#[1234567, 2345671, 3456712, 4567123, 5671234, 6712345, 7123456]
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
foo = "1234"
for i in range(len(foo)):
print(foo[i:] + foo[:i])
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Easy ;)
a = [1,2,3,4,5] # put in whatever you like
for i in range(len(a)):
print a[i:]+a[:i]
I recommend you have more reading about the python list object,
you'll be surprised of what it can give you
a = [1,2,3,4,5] # put in whatever you like
for i in range(len(a)):
print a[i:]+a[:i]
I recommend you have more reading about the python list object,
you'll be surprised of what it can give you
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询