반응형
Python supports string formatting three different ways.
1. %-formatting
2. str.format()
3. f-strings
I have used str.format() to print data so fat but I change my mind after knowing f-strings formatting.
name = 'Ethan'
age = 32
print (f'My name is {name} and I am {age} years old.')
name = 'Ethan'
age = 32
print (f'My name is {name} and I am {age} years old.')
The f-strings formatting sytax is f 'string ... ... {variable} .... {variable} ....'
반응형
'<개인공부> - IT > [Python]' 카테고리의 다른 글
Openpyxl - Make a report template (0) | 2020.07.30 |
---|---|
How to get a dict key in the list (0) | 2020.06.13 |
List comprehension (0) | 2020.03.30 |
Python regular expression match and search methods (0) | 2020.03.24 |
International Morse code (di-dah) (0) | 2019.02.25 |