代码基于Python3.6.4进行测试
#字符串遍历
foo = 'xyz'
for ch in foo:
print(ch)
foo = 'xyz'
for i,ch in enumerate(foo):
print(ch, '[%d]' % i)
#字符串替换
foo = 'xyz\r\nabc'
bar = foo.replace('\r\n', '')
print(bar)
#字符拼接
arr = []
arr.append('a')
arr.append('b')
arr.append('c')
print("".join(arr))#输出abc