x = f'{1}{2}{3}'
a = "one"
b = "two"
c = "three"
#I want to print "onetwothree"
I don't even know how to explain this problem, I froze up every time I started typing anything into google. Haven't tried anything yet, since I don't even know where to start. Help.
You can insert the variables' name inside the brackets of the f-string.
a = "one"
b = "two"
c = "three"
print(f'{a}{b}{c}')
>>> onetwothree
Put the variable names into the f-string.
print(f"{a}{b}{c}")
x = f'{1}{2}{3}'
a = "one"
b = "two"
c = "three"
#I want to print "onetwothree"
print(f"{a}{b}{c}")
Explanation: for every variable x
, you fill in with {x}
. For python 3, you use the print(item)
function if you want to print out an item.
The print() function prints the specified message to the screen, or other standard output device. The message can be a string, or any other object, the object will be converted into a string before written to the screen.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.