import pandas as pd
# 加载文件1,使用默认列名
file1 = pd.read_csv("test.txt", sep='\s+', header=None)
# 加载文件2,使用默认列名
file2 = pd.read_csv("t.txt", sep='\s+', header=None)
"""compare_column_index1 = 0 # 假设你想比较文件1中的某一列。
compare_column_index2 = 0 # 假设你想比较文件2中的某一列。"""
for index1, row1 in file1.iterrows(): # row1是test.txt里的内容
for index2, row2 in file2.iterrows(): # row2是t.txt里的内容
if row1[0] == row2[11]: # 比较文件1和文件2的第一列
file2.at[index2, 'total_length'] = row1.iloc[1] # 修改文件2的'total_length'列为文件1的第二列
#print(row1[0]) # 打印文件1的第一列
print(file2)