Python/Python Programming
[Python] 문자열 100개씩 잘라서 출력하기
Pydole
2018. 5. 14. 17:26
로그나 문자열이 너무 길면 일정길이로 짤라서 라인으로 출력할 필요가 있다.
s = 'Python is Beautiful' * 10
start = 0
end = 100
while True:
print(s[start:end],end='\n')
if len(s[end:]) < 101:
print(s[end:])
break
else:
start = end + 1
end += 101
-------------------------------------------------------------
Python is BeautifulPython is BeautifulPython is BeautifulPython is BeautifulPython is BeautifulPytho
n is BeautifulPython is BeautifulPython is BeautifulPython is BeautifulPython is Beautiful