簡體   English   中英

If語句Python 3.3.4語法錯誤

[英]If statement Python 3.3.4 syntax error

我是Python的新手,必須為我的課程創建一個溫度轉換器,下面是我的起點。 這使我在冒號上出現語法錯誤,並且嘗試了半冒號和逗號,卻不知道該怎么做。 就像我說的是編程新手,所以非常感謝所有幫助。

scale = float(input("If you would like to convert to Farenheint, write '1'.     
If you would like to convert to Celcius, write '2'"))                   
if scale == 1 : print("Please print your temperature using numbers only")

float行的末尾出現語法錯誤。 我建議將您的引號( " )更改為三引號( """ ),這表示您有一個阻止字符串。 嘗試這個:

scale = float(input("""If you would like to convert to Farenheint, write '1'.     
If you would like to convert to Celcius, write '2'"""))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM