微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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')

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐