2024-04-26 13:55:28 发布
网友
我有理由直接给int.__format__打电话。我试了以下方法
int.__format__
>>> object.__format__(1,'d')
但有个例外
TypeError: unsupported format string passed to int.__format__
fmt_spec应该是什么?你知道吗
fmt_spec
object.__format__称为object.__format__,而不是int.__format__。你知道吗
object.__format__
请尝试以下操作:
>>> (1).__format__('d') '1'
传递给object.__format__的非空字符串的行为是documented:
Changed in version 3.4: The __format__ method of object itself raises a TypeError if passed any non-empty string.
__format__
object.__format__
称为object.__format__
,而不是int.__format__
。你知道吗请尝试以下操作:
传递给
object.__format__
的非空字符串的行为是documented:相关问题 更多 >
编程相关推荐