250x250
Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

devlog_owen

파이썬의 f-string(f-문자열) 기능 본문

TIL

파이썬의 f-string(f-문자열) 기능

developer_owen 2024. 7. 9. 11:43
728x90

f-string이란?

  • 파이썬에서 문자열을 포맷팅하는 방법
  • 문자열 앞에 f를 붙이고 문자열 안에서 '{}'을 통해 변수나 표현식 삽입

기본문법

name = "Alice"
greeting = f"Hello, {name}!"
print(greeting)  # Hello, Alice!

 

def get_greeting(name):
    return f"Hi, {name}!"

greeting = get_greeting("Bob")
print(greeting)  # Hi, Bob!

 

 

출처:

 

7. Input and Output

There are several ways to present the output of a program; data can be printed in a human-readable form, or written to a file for future use. This chapter will discuss some of the possibilities. Fa...

docs.python.org

 

728x90