728x90
문자열 포맷팅
for i in range(2,10) :
for j in range(1,10):
print ( i, '*', j, '=', i*j )
1. 서식문자 표기법 # 구식, 비추
정수들어갈 자리 %d, 실수 %f, 문자열 %s
print( '%d x %d = %d' % (i, j, i*j))
2. 문자열 format 함수 사용
들어갈 자리 {}
print ( '{} x {} = {}'.format(i,j,i*j))
3. f string 사용 # 많이 사용
{} 뚫어주고 즉시 매워줌
print( f'{i} x {j} = {i*j}' )
728x90
'Progremming Study > python' 카테고리의 다른 글
Python 제어문 _ 반복문 _ while, while True (0) | 2022.05.21 |
---|---|
Python 제어문 _ 반복문 _ break, continue (0) | 2022.05.21 |
Python 제어문 _ 반복문 중첩 (0) | 2022.05.20 |
Python 제어문 _ 반복문 _ 복합 연산자, factorial 프로그램 (0) | 2022.05.19 |
Python 제어문 _ 반복문 _ range() (0) | 2022.05.19 |