cit*_*txx 15
你可以使用重复(*):
print('String' * 500)
Run Code Online (Sandbox Code Playgroud)
通过这种方式,Python将首先"StringStr...String"在内存中创建整个string(),然后才会打印它.
如果你不想使用这么多内存,那么你可以使用for循环:
for i in range(500):
print('String', end='')
print()
Run Code Online (Sandbox Code Playgroud)
end=''需要防止Python在每个字符后打印行尾字符print.print()最后需要在最后一行之后打印行尾字符print.
| 归档时间: |
|
| 查看次数: |
26606 次 |
| 最近记录: |