python - 你能看一下下面的代码吗,它不起作用并弹出:“TypeError: unsupported operand type(s) for /: 'str' and 'int'”。请
问题描述
你的老师要求你将大量的温度读数从摄氏温度转换为华氏温度。他们为您提供了使用公式:F = C * 9/5 + 32
C 是以摄氏度为单位测量的温度 F 是温度是华氏度
我的代码:
c = input("celsius: ")
f = c*9/5+32
print(c," degrees Celcius is ",f," degrees fahrenheit")
解决方案
f = int(c)*9/5+32
这应该可以将摄氏温度转换为华氏温度,但这只是一个近似值......
推荐阅读
- reactjs - React Router 中的“React 无法识别 DOM 元素上的道具”
- java - InputStream 和 BufferedReader
- java - 如何将驱动程序分配给 UNO DiscardPile.java?
- python - 仅在从相邻文件导入函数时发生错误
- javascript - 试图理解 node.js REPL 中的 spawn
- javafx - 使用带有文本字段的子字符串方法时出错
- java - 从 java Grpc 服务器调试线程转储?
- c++ - 实现链表时程序挂起
- css - WTForms 标签位置/隐藏标签
- go - k8s go客户端:如何将v1.Deployment类型传递给函数