[英]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
.因此title
是None
。
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.