📜  如何在 python 中读取数据文件并构建文件列表 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:50.184000             🧑  作者: Mango

代码示例1
f = open("RandomNames.txt", "r") rowList = [] for line in f.readlines(): rowList.append(line[0:-1]) print(rowList) f.close() f = open("RandomNames.txt", "r") idList = [] for line in f.readlines(): temp = line.split(",") idList.append(int(temp[0])) print(idList) f.close()