So fügen Sie eine Variable in eine String -Python ein
>>> name = "Fred"
>>> f"He said his name is {name}."
'He said his name is Fred.'
Happy Hippopotamus
>>> name = "Fred"
>>> f"He said his name is {name}."
'He said his name is Fred.'
#Pre 3.6
print('Hi, my name is {name} and my age is {age}'.format(**locals()))
#After 3.6
print('Hi, my name is {name} and my age is {age}')
>>> line = 'Kong Panda'
>>> index = line.find('Panda')
>>> output_line = line[:index] + 'Fu ' + line[index:]
>>> output_line
'Kong Fu Panda'