且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python,无法打开文本文件

更新时间:2023-10-17 17:40:34

结果将是空字符串而不是空列表,这是因为您的文件大小大于 你的内存(基于你的python版本和你的机器)!所以python并没有将文件内容赋值给一个变量!

The result would be empty string not empty list and it's because your file size is larger than your memory(based on your python version and your machine)! So python doesn't assigned the file content to a variable!

要解决这个问题,您需要逐行处理您的文件.

For getting rid of this problem you need to process your file line by line.

with open('/home/user/android.txt') as f :
    for line in f:
         #do stuff with line