在Python中,可以使用\n來表示換行符。下面是一個示例,演示了如何使用換行符來將字符串變量拼接成多行:
\n
str1 = "Hello" str2 = "World" str3 = "Python" result = str1 + "\n" + str2 + "\n" + str3 print(result)
運行上面的代碼,輸出結果為:
Hello World Python
這樣就實現了字符串變量的拼接并換行顯示。