Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
int.\uu格式的python格式规范___Python - Fatal编程技术网

int.\uu格式的python格式规范__

int.\uu格式的python格式规范__,python,Python,我有理由想直接调用int.\uu格式\uu。我尝试了以下方法 >>> object.__format__(1,'d') 但是有一个例外 TypeError: unsupported format string passed to int.__format__ fmt\u规范应该是什么?对象。格式称为对象。格式,而不是内部格式 请尝试以下方法: >>> (1).__format__('d') '1' 通过将非空字符串传递给对象,您看到的行为是: 在版本3.

我有理由想直接调用
int.\uu格式\uu
。我尝试了以下方法

>>> object.__format__(1,'d')
但是有一个例外

TypeError: unsupported format string passed to int.__format__

fmt\u规范
应该是什么?

对象。

格式
称为对象。格式,而不是
内部格式

请尝试以下方法:

>>> (1).__format__('d')
'1'
通过将非空字符串传递给
对象,您看到的行为是:

在版本3.4中更改:如果传递了任何非空字符串,则对象本身的
\uuuuuu格式\uuuuuu
方法将引发TypeError