python
import pandas as pd
def txt_to_excel(txt_file, excel_file):
# 读取 txt 文件
with open(txt_file, 'r') as f:
lines = f.readlines()
# 将每行数据分割成多个单元格
data = []
for line in lines:
row = line.strip().split(' ')
data.append(row)
# 将数据保存到 Excel 文件
df = pd.DataFrame(data)
df.to_excel(excel_file, index=False, header=False)
# 文件名
file_name = '100-100圆柱'
# 调用函数,传递变量作为参数
txt_to_excel(file_name+'.txt', file_name+'.xlsx')
图示