devlog_owen
파이썬의 f-string(f-문자열) 기능 본문
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
'TIL' 카테고리의 다른 글
python 딕셔너리 검색 (0) | 2024.07.10 |
---|---|
주석 안먹힐때(ctrl+/ 안먹힐때) (0) | 2024.07.10 |
MySQL 배열로 데이터 저장하기 (+nest.js, swagger) (0) | 2024.03.05 |
[TIL] Redis maxmemory 설정, LRU 캐시전략 설정하기 (0) | 2024.01.29 |
[TIL]Nest can't resolve dependencies of the StorebookService 오류 해결 (0) | 2024.01.22 |