- 2
- 이니스프리
- 조회 수 753
버전 2.X에서 지원하던 방식으로서, 다른 언어와 유사합니다.
물론 버전 3.X에서도 사용 가능합니다.
print('This is text %s. This is number %d.' %(string, number))버전 3.X에서 추가적으로 지원하는 형식입니다.
print('{0} and {1}'.format('Simon', 'Garfunkel'))버전 2.X에서 지원하던 방식으로서, 다른 언어와 유사합니다.
물론 버전 3.X에서도 사용 가능합니다.
print('This is text %s. This is number %d.' %(string, number))버전 3.X에서 추가적으로 지원하는 형식입니다.
print('{0} and {1}'.format('Simon', 'Garfunkel'))
python 3.6 이상부터는 아래와 같이 쓸 수도 있습니다.
s1 = 'Simon' s2 = 'Garfunkel' print(f'{s1} and {s2}')