【发布时间】:2019-02-24 04:33:30
【问题描述】:
我在 text.txt 文件中有数据
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[[10, 11, 12], [13, 14, 15], [16, 17, 18]]
等等 我想读取文本文件的每一行并将它们视为整数,例如在 3d 空间中绘制这些点。当我通过
导入文件时with open('text.txt') as f:
content = f.readlines()
for x in content:
print(x)
它是:
'[','[','1' etc...
所以我很困惑使用什么作为 split() 函数的分隔符。将不胜感激一些建议。 提前致谢。
【问题讨论】:
标签: python string split python-import readlines