python读取txt大文件

直接上代码:

import easygui
import os
s4 = []
s6 = []
path = easygui.fileopenbox()
if path:
    b = os.path.splitext(path)
    c = [b[0], '_trace', '.xyz']
    d = ''.join(c)
    with open(d, 'w+') as f1:
        with open(path, 'r', encoding='utf-8') as f:
            for line in f:
                s1 = line.strip()
                s2 = (s1.strip().split(' ')[-6:-3][::-1])
                s3 = ' '.join(s2)
                f1.writelines(s3)
                f1.writelines('\n')
View Code

猜你喜欢

转载自www.cnblogs.com/yibeimingyue/p/10041461.html