Here是对旧式字符串格式的描述,其中规定了八进制和十六进制值的转换。 我已经尝试过语法,但是发生了一些意想不到的事情
代码'%#07x' % 1223
和'%#07o' % 1223
的结果格式相似,分别为'0x004c7'和'0o02307'。但是,有关八进制值的相关描述与行为不匹配
The alternate form causes a leading zero ('0') to be inserted between left-hand padding and the formatting of the number if the leading character of the result is not already a zero.
所有代码都在CPython的交互式解释器中执行,版本为3.5.2
我已经向Python社区报告了这个问题,bug已经被修复了,前面的描述已经被修改为正确的描述。 请参阅Notes部分,第1行
相关问题 更多 >
编程相关推荐