-
Python string interpolation카테고리 없음 2020. 10. 29. 08:10
Javscript에서는 string interpolation하는 방법을 알고 있었는데, python에서는 몰라서 검색해봤다. 여태 프로그래밍 과제에서는 format() function을 사용해왔었는데(이걸로 interpolation하고 있었다는 사실은 까먹었었다) 이거보다 편한게 f-string이라는 걸 알게 되었다.
www.programiz.com/python-programming/string-interpolation
Python String Interpolation
String interpolation is a process substituting values of variables into placeholders in a string. For instance, if you have a template for saying hello to a person like "Hello {Name of person}, nice to meet you!", you would like to replace the placeholder
www.programiz.com
위 웹사이트에서
name = 'World'
program = 'Python'
print(f'Hello {name}! This is {program}')
다음과 같은 예제를 들었는데 너무 간결했다. 앞으로는 interpolation할 때 f-string을 사용해야겠다.