首页 > 解决方案 > 为什么 python {:016X} .format() 说明符在 Brython 中不允许大于 2**52 的大小?

问题描述

我应该能够将一个高达 ( 2**64)-1 的值转换为一个零填充的 16 位十六进制半字节字符串......那么为什么当我达到超过的大小时会出现以下错误2**52

>>> a = "{:016X}".format(2**52)
>>> a = "{:016X}".format(2**53)
Traceback (most recent call last):
  File <string>, line 1, in <module>
TypeError: non-empty format string passed to object.__format__

这是否与 Brython 的限制有关,它将事物转换为 javascript?(因为我在这里的 Brython REPL 中得到了那个错误,但在本地正常的 Python3 REPL 中没有)

标签: pythonstringformatbrython

解决方案


看起来开发人员确认这是一个错误: https ://github.com/brython-dev/brython/issues/1624


推荐阅读