简体   繁体   English

获取“传递给 NoneType 的不支持的格式字符串。__format__”错误

[英]Getting "unsupported format string passed to NoneType. __format__" error

I'm getting the unsupported format string error message from the following code;我从以下代码中收到不支持的格式字符串错误消息;

title = print("SCHEDULE")
                                                                
print(f"{title: >50}")

I've done this countless times before without any issues, strange how it's coming up now?我以前做过无数次,没有任何问题,奇怪现在怎么样了? Am I being completely blind to something?我对某事完全视而不见吗?

I tried to above, as I have done many times before, but only now getting the error.我在上面尝试过,就像我以前做过很多次一样,但直到现在才收到错误。

The print() function doesn't return anything. print() function 不返回任何内容。 Therefore title is None .因此titleNone

The raised error is because a NoneType (in this case the value the title variable holds) can't be formatted (it's not a str as I suppose you'd like).引发的错误是因为无法格式化NoneType (在本例中为title变量保存的值)(它不是我想你想要的str )。

Try title = "SCHEDULE" without printing.尝试title = "SCHEDULE"而不打印。

暂无
暂无

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

相关问题 传递给 NoneType.__format__ 的格式字符串不受支持 - Unsupported format string passed to NoneType.__format__ 不支持的格式字符串传递给 NoneType.__format_ - Unsupported format string passed to NoneType.__format_ Python:TypeError:不支持的格式字符串传递给 NoneType.__format__ - Python: TypeError: Unsupported format string passed to NoneType.__format__ RaspberryPi:TypeError:不支持的格式字符串传递给 NoneType.__format__ - RaspberryPi: TypeError: unsupported format string passed to NoneType.__format__ TypeError:不支持的格式字符串传递给 NoneType.__format__ - TypeError: unsupported format string passed to NoneType.__format__ 我收到程序错误:“不支持的格式字符串传递给 list.__format__” - I am getting an error on program: “unsupported format string passed to list.__format__” TypeError:不支持的格式字符串通过 Python 中的 f 字符串传递给 NoneType.__format__ - TypeError: unsupported format string passed to NoneType.__format__ with f-string in Python TypeError:不支持的格式字符串传递给 NoneType.__format__(我不知道这是什么意思) - TypeError: unsupported format string passed to NoneType.__format__(I do not know what this means) TypeError: python 中覆盆子项目传递给 NoneType.__format__ 的格式字符串不受支持 - TypeError: unsupported format string passed to NoneType.__format__ for a raspberry project in python RaspberryPi: TypeError: 不支持的格式字符串传递给 NoneType.__format__ dht22 lcd 16x2 - RaspberryPi: TypeError: unsupported format string passed to NoneType.__format__ dht22 lcd 16x2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM