[英]Formatted string hell - Python
x = f'{1}{2}{3}'
a = "one"
b = "two"
c = "three"
#I want to print "onetwothree"
我什至不知道如何解釋這個問題,每次我開始在谷歌中輸入任何內容時,我都愣住了。 還沒有嘗試任何東西,因為我什至不知道從哪里開始。 幫助。
您可以在 f 字符串的括號內插入變量的名稱。
a = "one"
b = "two"
c = "three"
print(f'{a}{b}{c}')
>>> onetwothree
將變量名稱放入 f 字符串中。
print(f"{a}{b}{c}")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.