【发布时间】:2015-05-23 01:42:36
【问题描述】:
我只是在每 3 个字符之间添加一个“,”时遇到问题。
print totalpoints
points = ','.join([totalpoints[i:i+3] for i in range(0, totalpoints, 3)])
输出:
875
TypeError: sequence index must be integer
【问题讨论】:
-
你能详细说明一下吗?
totalpoints是什么?如果它不是字符串/list,你认为你会如何使用slice?
标签: range python-2.5