C:\Users\Administrator\AppData\Local\Programs\Python\Python311\python.exe C:/Users/Administrator/PycharmProjects/test/venv/789.py 请输入你的性别:男 请输入你的身高(厘米):175 Traceback (most recent call last): File "C:\Users\Administrator\PycharmProjects\test\venv\789.py", line 10, in <module> print(f"你的性别是:{people},身高是:{height} 厘米,标准体重应该是:{standard_weight:.1f} 公斤") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: unsupported format string passed to list.__format__
时间: 2023-07-21 18:35:50 浏览: 93
This error occurs when you try to use the format method on a list object instead of a string object.
In your code, it seems that you are trying to use the format method on a list object when printing the result:
```
print(f"你的性别是:{people},身高是:{height} 厘米,标准体重应该是:{standard_weight:.1f} 公斤")
```
The error message indicates that the format method is being called on a list object instead of a string object when trying to format the value of the `standard_weight` variable.
To fix this error, you need to make sure that you are formatting a string object instead of a list object. One way to do this is to convert the list object to a string using the `join` method:
```
print("你的性别是:{},身高是:{} 厘米,标准体重应该是:{:.1f} 公斤".format(people, height, standard_weight))
```
This will format the string correctly and prevent the TypeError.
阅读全文