-
一行打印十个小星星
i = 0 while i < 10: print("*", end='') i += 1
通过一个变量打印出一行小星星 字符串的拼接 i = 0 star = "" while i < 10: # 写上逻辑 star += "*" i += 1 print(star)
-
一行隔列变色小星星 ★☆★☆★☆★☆★☆
i=0 while i < 10: if i % 2 == 0: print("★", end="") else: print("☆", end="") i += 1
字符串拼接 i = 0 star = "" while i < 10 : if i % 2 == 0: star += "★" else: star += "☆" i += 1 print(star)
-
十行十列小星星
找到当前这行的第10个星星换行; i = 0 while i < 100: print("*", end="") if i % 10 == 9: print() i += 1
用两个循环完成十行十列的小星星 k =
python--打印星星
最新推荐文章于 2024-03-20 15:13:35 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)