python - 在python中向字符串添加空字符

标签 python

我有如下列表:

['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/

相关文章:

python - 如何使用 Seaborn 绘制离散概率分布?

Python:共享 os.system 调用的命令行参数

python - 使用python将google docs公共(public)电子表格下载到csv

python - Sublime Text 将 PATH 设置为预安装的 Anaconda 和 Tensorflow

python - 平滑跳过不同的 FPS

Python - 缩短 if/for 循环

python - 如何从列表中打开文件

python多处理写入共享文件

python - Django如何在一个url地址调用多个 View ?

python - 在键 "foo"后面插入 OrderedDict(就地)