一个txt文件内容为000000000036.jpg,216,257,208,257,230,257,257,255,243,208,216,211,hand 000000000036.jpg,419,469,339,386,449,339,419,343,439,386,469,381,hand 000000000077.jpg,29,47,254,276,47,259,38,254,29,272,38,276,hand 000000000077.jpg,291,307,58,69,291,62,294,69,307,65,305,58,hand 000000000077.jpg,292,305,58,69,292,63,295,69,305,64,302,58,hand 000000000077.jpg,307,315,76,86,315,78,311,76,307,85,311,86,hand 000000000165.jpg,109,182,210,253,109,224,116,253,182,239,174,210,hand 000000000165.jpg,219,274,262,312,243,262,219,280,250,312,274,294,hand 000000000165.jpg,185,237,217,257,226,257,237,229,195,217,185,245,hand 000000000165.jpg,244,298,170,202,293,202,298,177,249,170,244,195,hand 000000000322.jpg,189,212,148,167,194,148,189,157,208,167,212,158,hand 000000000322.jpg,53,75,163,186,75,171,65,163,53,178,63,186,hand 000000000389.jpg,426,446,246,264,440,264,446,255,432,246,426,255,hand 000000000431.jpg,218,231,148,159,219,148,218,156,230,159,231,151,hand,将所有的行存在list
时间: 2023-09-22 11:08:48 浏览: 116
这是txt文件数据
要将txt文件中的每一行存储在一个列表中,可以使用以下代码:
```python
data_list = []
# 打开txt文件
with open("your_file.txt", "r") as file:
# 逐行读取文件内容
for line in file:
# 去除行尾的换行符
line = line.strip()
# 将行添加到列表中
data_list.append(line)
```
请将`your_file.txt`替换为实际的txt文件路径。执行上述代码后,您将获得一个名为`data_list`的列表,其中包含了txt文件中的每一行数据。您可以进一步使用这个列表进行后续处理或分析。
阅读全文