“Python F string” Kode Jawaban

string f

var = 1
print(f'number {var}')
A DG

Python F string

'''
In python, rather than adding pieces of string together, you can use
f-strings to insert variables into strings. This makes your code much
more easier to read.
'''

# OLD - WITHOUT F-STRINGS
name = 'Bob'
age = 12
print('This is ' + name + ', he is ' + age + ' years old.')

# NEW - WITH F-STRINGS
print(f'This is {name}, he is {age} years old') # Note the f in front
Ninja Penguin

Jawaban yang mirip dengan “Python F string”

Pertanyaan yang mirip dengan “Python F string”

Lebih banyak jawaban terkait untuk “Python F string” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya