小编sha*_*ath的帖子

如何在python中将文件的内容写入列表?

我正在学习python编程并且遇到了这个问题.我查看了其他读取文件输入的示例,并将整个事件作为单个列表或作为该示例的字符串链接, 但我希望每行都是一个列表(嵌套列表)我该怎么做请帮助
文本文件是a.txt

1234 456 789 10 11 12 13

4456 585 568 2 11 13 15 
Run Code Online (Sandbox Code Playgroud)

代码的输出必须是这样的

[ [1234 456 789 10 11 12 13],[4456 585 568 2 11 13 15] ]
Run Code Online (Sandbox Code Playgroud)

python nested-lists python-2.7

3
推荐指数
1
解决办法
135
查看次数

标签 统计

nested-lists ×1

python ×1

python-2.7 ×1