從變量打印時,有什麼辦法避免打印數據(如引號,括號,逗號和其他重要的元素符號)?如何刪除引號(和其他標記)?
int1 = random.randint(1,100)
int2 = random.randint(1,100)
q1 = "What is", int1, "+", int2, "?"
answer = int(raw_input(q1))
上述打印該代碼:
('What is', 75, '+', 74, '? ')149
打印上面會理應是本的正確的方法:
What is 75 + 74? 149
'q1'是一個元組。如果你想創建一個字符串,使用'+'連接並使用'str'將數字顯式轉換爲字符串。 – Bakuriu