python-3.x - 如何在Python列表中的每个元素后插入空格
问题描述
我有一个看起来像这样的列表'decrypted_characters'
['mathematician', 'to', 'present', 'a', 'proof', 'of', 'the', 'sensitivity']
我希望它看起来像一个段落,所以我尝试了
decrypted_word = ''.join(decrypted_characters)
当我打印时它看起来像
数学家提出敏感性证明
如何在每个元素后添加空格使其看起来像句子?我希望它看起来像
数学家提出敏感性证明
谢谢!
解决方案
使用join
:
In [4]: ' '.join(['mathematician', 'to', 'present', 'a', 'proof', 'of', 'the', 'sensitivity'])
Out[4]: 'mathematician to present a proof of the sensitivity'
推荐阅读
- python - Python 中具有绝对值的 CPLEX 约束
- ios - 由于 iOS 上的白屏未捕获异常“NSInternalInconsistencyException”而终止应用程序
- sql - 在 Oracle SQL 的同一查询中使用 IN 和 NOT IN
- javascript - 如何使用 Dropzone js 显示文件的上传百分比?
- python - 使用 python 获取对 aspx 站点的 GET 请求时出现问题。“你调用的对象是空的”
- javascript - 如何更改数组包含
- python - 如何在 HTML 中使用 {{ url '' }} 和 url 引用的变量
- python - 在 ubuntu 上安装 devstack train 时解决错误
- java - 无法从我的代码中计算当天的总销售额,每次显示为零(0)
- rxjs - 如何正确使用 asyncScheduler 来了解 rxjs 中处理的数据?