为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我这样写,输出的是同样的结果循环了循环了很多次:

L=range(1,101)
for i in L:
    print L[6::7]
   

结果:

[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]

正在回答

2 回答

这不是相当于从L中取元素赋值给i,然后再执行 print L[6::7],取了100次,就执行print L[6::7]一百次

0 回复 有任何疑惑可以回复我~
#1

qq_初妆_0 提问者

非常感谢!
2016-03-16 回复 有任何疑惑可以回复我~

L=range(1,101)
print L[6::7]

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
初识Python
  • 参与学习       758625    人
  • 解答问题       8667    个

学python入门视频教程,让你快速入门并能编写简单的Python程序

进入课程

为什么我这样写,输出的是同样的结果循环了循环了很多次:

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信