0
我\n
不`噸工作 這裏是我的代碼:換行 n不工作
s = 0
a = 0
w = 0
h = 0
stats = "1. Strength - ", s, "\n2. Agility - ", a, "\n3. Wisdom - ", w, "\n4. Health - ", h
print(stats)
當試圖啓動程序我得到這個:
('1. Strength - ', 0, '\n2. Agility - ', 0, '\n3. Wisdom - ', 0, '\n4. Health - ', 0)
順便說一句,我需要我的s
,a
,w
,h
變量作爲整數。
如果這是python3.x,你可以簡單地做--' print(* stats)'。 –
@AnandSKumar,謝謝,它的工作原理。 – pookeeshtron
原因是你將'stats'存儲爲元組,而不是字符串。所以當你打印它時,它會打印一個元組。 *運算符Anand建議解包元組。 – BlivetWidget