Backspace does not seem to work in python
问题 network={1:[2,3,4],2:[1,3,4], 3:[1,2], 4:[1,3,5], 5:[6,7,8], 6:[5,8],7:[5,6], 8:[5,6,7]} str1='network.csv' output = open(str1,'w') for ii1 in network.keys(): output.write(repr(ii1)+":[") for n in network[ii1]: output.write(' %s,'%(repr(n))) output.write('\b'+']\n') output.close() What I expect is something like: 1:[ 2, 3, 4] 2:[ 1, 3, 4] 3:[ 1, 2] 4:[ 1, 3, 5] 5:[ 6, 7, 8] 6:[ 5, 8] 7:[ 5, 6] 8:[ 5, 6, 7] but what I get is: 1:[ 2, 3, 4,] 2:[ 1, 3, 4,] 3:[ 1, 2,] 4:[ 1, 3, 5,] 5:[ 6, 7, 8,] 6