f-string1 파이썬 f-string f-string은 직관적이라 좋다. 파이썬 3.6에 처음 등장했다고 한다. format 메소드와 동일하게 서식 추가 또한 가능하다. a, b, c = 1, 2, 3 print(f'a = {a}, b = {b}, c = {c}') print(f'{a} + {b} + {c} = {a + b + c}') print() n = 123456 print(f'n = {n:4}') print(f'n = {n:6}') print(f'n = ({n:b})2') # 2진수 print(f'n = ({n:o})8') # 8진수 print(f'n = ({n})10') # 10진수 print(f'n = ({n:x})16') # 16진수 print(f'n = ({n:X})16') # 16진수 대문자 print() f = 7.123 .. 2022. 2. 17. 이전 1 다음 728x90