如何将特殊字符放入输入的文本中

时间:2017-01-14 15:29:41

标签: python python-3.x

我刚刚进入python,我的任务是将Celsius写入Farenheit(反之亦然)转换器。我获得了加入学位符号的奖励积分。

我希望在初始输入问题的文本中显示degree_symbol

degree_symbol = chr(176)
temperature = input("Is your temperature in", degree_symbol, "F or", degree_symbol, "C?\n")

if temperature == "C":
    temp_c = float(input("What is your temperature in C?\n"))
    print("That is", ((temp_c * (9/5)) + 32), degree_symbol, "F!") 

else:
    temp_f = float(input("What is your temperature in F?\n"))
    print("That is", ((temp_f - 32) * (5/9)), degree_symbol, "C!")  

这是出现的错误

    3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)]
Python Type "help", "copyright", "credits" or "license" for more information.
[evaluate -------_As01.py]
Traceback (most recent call last):
  File "C:/Users/-----------/----------_As01.py", line 10, in <module>
    temperature = input("Is your temperature in", degree_symbol, "F or", degree_symbol, "C?\n")
builtins.TypeError: input expected at most 1 arguments, got 5

0 个答案:

没有答案