TypeError: sequence index must be integer
本问题已经有最佳答案,请猛点这里访问。
我只是在每3个字符之间添加一个","有问题。
1 2 | print totalpoints points = ','.join([totalpoints[i:i+3] for i in range(0, totalpoints, 3)]) |
输出:
1 2 | 875 TypeError: sequence index must be integer |
我不知道你到底想干什么。但如果我没有错的话,下面会解决你的问题。
1 2 3 4 5 | >>> totalpoints = 875123123 >>> totalpoints = str(totalpoints) >>> points = ','.join([totalpoints[i:i+3] for i in range(0, len(totalpoints), 3)]) >>> points '875,123,123' |