python - 如何将整个文件读入python中的列表?

标签 python

我想将整个文件读入 python 列表,有人知道怎么做吗?

最佳答案

更简单:

with open(path) as f:
    myList = list(f)

如果你不想换行,你可以做 list(f.read().splitlines())

关于python - 如何将整个文件读入python中的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6720417/

相关文章:

python - Numpy - 使用 numpy.fromfunction 构建 Jaro(或 Levenshtein)距离矩阵

python - 如何绘制一个wav文件

python - 收到 ValueError : Unknown level when running GoogleScraper

python - 是否需要在 Flask 应用程序中关闭 python SQL 连接?

python - 如何在 python 程序中使用 youtube-dl?

python - 将函数内部的变量传递给函数外部的变量

python - getaddrinfo失败,出现socket.gaierror [11001](python)(mqtt)

python:像整数一样的 float

python - asyncio.gather() - task.cancelled() 在 task.cancel() 之后为 False

Python 短网址扩展器