python - 将列表输入转换为字符串输出
问题描述
我有一个如下列表,我可以知道如何转换为字符串输出吗?
Input
A = [['I', 'love', 'apple','.'],
['Today', 'is', 'Sunday', '.'],
['How', 'are', 'you'],
['What', 'are', 'you','doing']]
Output
I love apple.
Today is Sunday.
How are you
What are you doing
解决方案
您可以简单地使用for
循环遍历嵌套在 list 中的每个列表A
。
A = [
['I', 'love', 'apple.'],
['Today', 'is', 'Sunday.'],
['How', 'are', 'you'],
['What', 'are', 'you', 'doing']
]
for row in A:
print(' '.join(row))
推荐阅读
- string - Python 中的运行时错误(TypeError:无法将 'float' 对象隐式转换为 str)
- c# - 如何在c#中将texbox格式化为NIC格式
- python - 如何测试任何给定网页页脚中的所有链接
- c++ - Openmp for loop:工作不平衡的静态调度
- ruby-on-rails - 更新博客 gem 中的 jekyll 主题
- python - 获取由未知分隔符分隔的字符串中的最后一个数字
- java - 使用协作线程添加二维数组
- sql - SQL 如何在不共享任何物理文件的情况下通过网络与数据库通信?
- apache-nifi - 如何在 nifi 中设置从 influxdb 到 hdfs 的数据流?
- javascript - 我如何翻译这个 javascript 代码