我有如下列表:
['t','e','s','t','s','t','r','i','n','g']
如何在每个字符串 t
, e
, s
, t
, 后添加空字符s
, t
, r
, i
, n
, g
?
最佳答案
列表理解。
[c + '\0' for c in S]
但它听起来像是您想要 UTF-16LE。
u'teststring'.encode('utf-16le')
关于python - 在python中向字符串添加空字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12016005/