。
这个需求可以通过编写一个循环来实现。具体步骤如下:
以下是一个示例的Python代码实现:
import time
pattern1 = [
"*********",
" * *",
" * * ",
" * * ",
" * * ",
" * ",
" * * ",
" * * ",
" * * ",
" * *",
"*********"
]
pattern2 = [
"#########",
" # #",
" # # ",
" # # ",
" # # ",
" # ",
" # # ",
" # # ",
" # # ",
" # #",
"#########"
]
while True:
line = input()
if line == "EOF":
break
elif line == "pattern1":
for row in pattern1:
print(row)
time.sleep(1)
elif line == "pattern2":
for row in pattern2:
print(row)
time.sleep(1)
这段代码会不断读取输入的行,如果输入为"pattern1",则打印第一个图案;如果输入为"pattern2",则打印第二个图案。每打印完一次图案,程序会休眠一秒钟,然后继续读取下一行,直到输入为"EOF",循环结束。
这个需求中并没有明确要求使用腾讯云相关产品,因此不需要提供相关产品和链接。
没有搜到相关的沙龙
领取专属 10元无门槛券
手把手带您无忧上云