Ansys采用后处理list Rusult输出位移时负号原因导致不能分列的python解决方法

'''
! ========== Creat Date: 2021-5-4 ==========
! ========== Author: xdd1997        ==========
! ========== Email: xdd2026@qq.com  ==========
'''

import re
#  ================ 输入文件 ================ # 接口  filePath = 'D:\\Desktop\\uu.lis'  也可以
filePath = r'D:\Desktop\PRNSOL.lis'
pathAndName = filePath.split(".")[0]
fileOutPath = pathAndName + '_change.txt'
# ================ 获取文件行数 ================
count = -1
for count, line in enumerate(open(filePath)):
    pass
count += 1
file_line = count
print(file_line)
# ================处理文件 ==================
kk =0
with open(filePath, 'r') as old_file:
    with open(fileOutPath, 'w') as new_file:
        for line in old_file.readlines():
             kk = kk + 1
             if ((kk>11) and (kk<(file_line-4))):
                 new_file.writelines(line[1:9] + ' ' +line[9:21] + ' ' + line[21:33] + ' ' + line[33:57]+'\n')

 

上一篇:怎样使用Python导入.txt的文本文件


下一篇:java六课时