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:DesktopPRNSOL.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]+'
')

转载仅为学习,不会商用。
欢迎转载原创,附文链接。
原文地址:https://www.cnblogs.com/xdd1997/p/14729525.html