小编SMP*_*288的帖子

将包含元组的列表转换为字符串

我有一个包含元组的列表.我需要将整个列表转换为字符串进行压缩.这段代码在Python 2.7中运行良好:

tt = '{}'.format(tt)
Run Code Online (Sandbox Code Playgroud)

但是在Python 2.6中我收到以下错误:

  hist = '{}'.format(hist)
ValueError: zero length field name in format
Run Code Online (Sandbox Code Playgroud)

tt看起来像是数据[(2, 3, 4), (34, 5, 7)...]

除了升级Python版本之外,还有什么解决方法吗?

python runtime-error

1
推荐指数
1
解决办法
479
查看次数

标签 统计

python ×1

runtime-error ×1