python - 我如何循环/重复/范围(无论你怎么称呼它)在python中打印文本?
问题描述
我在这段代码中做错了什么,它不会循环打印?请发送正确答案。
repr(
"input()means you tell the computer something"
)
range(
"input()means you tell the computer something"
)
解决方案
我不太确定你想用这段代码实现什么,但是有多种方法可以在 python 中重复打印一个字符串。这里有几种方法:
- 使用 while 循环(这将无限运行)
while True:
print("input()means you tell the computer something")
- 使用 for 循环(如果您想打印一定次数)
times = int(input("How many times do I repeat?: "))
for i in range(times):
print("input()means you tell the computer something")
我希望这能回答你的问题
推荐阅读
- gremlin - Gremlin 查询跨顶点搜索子字符串
- html - 添加集成的文本/图像 CSS
- php - 如何在 symfony 3.4 中正确验证 JSON 请求
- google-cloud-storage - 无法导入名称“ClientWithProject”
- java - 在java中将csv文件写入gzip
- c++ - 如何在 C++ 中遍历 google protobuf 映射?
- android - 带有阿拉伯数字的 Android EditText
- ios - 如何检查播放器中是否存在音频流。AVPlayer, 迅速 3
- php - Vue组件未在基本php中呈现
- c# - 使用 NSubstitute 模拟出现问题时抛出异常的方法