Discuss / Python / 求助

求助

Topic source

木水Joe

#1 Created at ... [Delete] [Delete and Lock User]

想写123123123的死循环,该怎么写?

木水Joe

#2 Created at ... [Delete] [Delete and Lock User]

#-*-coding:UTF-8 -*-

n=1

while n>0:

    print(n)

    n=n

#死循环作业

木水Joe

#3 Created at ... [Delete] [Delete and Lock User]

#-*-coding:UTF-8 -*-

n=1

while n>0:

    if n>3:

        continue

        #这里执行后,要是加上返回从1开始重新输入,那还是死循环吗?我的逻辑是不是错了?

    print(n)

    n=n+1

你说的是这样吗

#!/usr/bin/env python3# -*- coding: utf-8 -*i = 1while i >= 1:    if i > 3:        i = 1    print(i)    i += 1
i=1while i >0:    print(i)    i=i+1    if i >3:        i=1        continue

这样是吗

i=1while i >0:    print(i)    i=i+1    if i >3:        i=1        continue

竹叶lcc

#7 Created at ... [Delete] [Delete and Lock User]

i=1

while i>0:

    print(i)

    i=i+1

    if i>3:

        i=1

Sunshine-贺

#8 Created at ... [Delete] [Delete and Lock User]
while True:    for i in list(range(3)):        print(i)

这样写他不香吗

小怪buguai

#9 Created at ... [Delete] [Delete and Lock User]

n=1

while True:

    print(n)

    n=n+1

    print(n)

    n=n+1

    print(n)

    n=n-2

while True:

for i in range(1,4):

print(i)


  • 1

Reply