简体   繁体   English

在我的情况下,“str”类型的 object 的“未知格式代码 'f' 是什么意思?

[英]What does "Unknown format code 'f' for object of type 'str' mean in my case?

This is part of a sort function I defined in a test file -- and it ran fine.这是我在测试文件中定义的 function 的一部分——它运行良好。 Then I transferred it to my main file and I'm getting all sorts of errors, mostly about mixing ints with strs, but also including this "f"-ing one, so to speak.然后我把它转移到我的主文件中,我得到了各种各样的错误,主要是关于将 int 与 strs 混合,但也包括这个“f”-ing 一个,可以这么说。 Could this mean that pygame doesn't support the f-string formatting of newer Python versions?这是否意味着 pygame 不支持较新 Python 版本的 f 字符串格式?

table = stat_font.render(
                    f"{teams[team][0]:12}{str(teamstats[team][0]):>2} - {str(teamstats[team][1]):>2} "
                    f"{str(teamstats[team][4]):6.3f}  {str(ptdif):>}", True, white)
```

It means exactly what the error message says: You are trying to use the :6.3f format specifier on a string, which doesn't support it.这正是错误消息所说的意思:您正在尝试在不支持它的字符串上使用:6.3f格式说明符。 Just remove the call to str in the f-string field.只需在 f-string 字段中删除对str的调用。 It is called automatically.它是自动调用的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型为'str'的对象的未知格式代码'f'-Folium - Unknown format code 'f' for object of type 'str'- Folium ValueError:类型为“str”的 object 的未知格式代码“f” - ValueError: Unknown format code 'f' for object of type 'str' 在代码中格式化不断导致 ValueError: Unknown format code 'f' for object of type 'str'? - Formatting in a code constantly causes the ValueError: Unknown format code 'f' for object of type 'str'? “str”类型对象的未知格式代码“g” - Unknown format code 'g' for object of type 'str' 类型“ str”的对象的未知格式代码“ b” - Unknown format code 'b' for object of type 'str' ValueError:类型为'str'的对象的未知格式代码'f'-为什么第二次却不是第一次? - ValueError: Unknown format code 'f' for object of type 'str' - why do I get this the second time but not the first time? 'unicode'类型对象的未知格式代码'f' - Unknown format code 'f' for object of type 'unicode' ValueError:类型为“ str”的对象的未知格式代码“ g” - ValueError: Unknown format code 'g' for object of type 'str' ValueError: 类型“str”的对象的格式代码“e”未知 - ValueError: Unknown format code 'e' for object of type 'str' 当 str 对象属性为“只读”时,这意味着什么? 如何修复我的代码? - What does it mean when a str object attribute is "read-only?" How do I fix my code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM