当前位置:   article > 正文

python中文文本分析和提取_python str(使用python对txt文本进行分析和提取)

python文本分析和提取

python 文本文件数据处理

#/usr/bin/env python3

# -*- coding: utf-8 -*-

def zhidao_560604345(infile, outfile):

reader = open(infile, 'r')

set_dict = {}

setenv_dict = {}

while True:

line = reader.readline()

if len(line) == 0:

break

a, b, c = line.strip().split(maxsplit=2)

if a == 'set':

if not b in set_dict:

set_dict[b] = set()

set_dict[b].add(c.strip())

elif a == 'setenv':

if not b in setenv_dict:

setenv_dict[b] = set()

setenv_dict[b].update(c.strip().split(':'))

reader.close()

buff = []

for k, v in set_dict.items():

buff.append('set %s "%s"' % (k, ':'.join(list(v))))

for k, v in setenv_dict.items():

tmp = []

for 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/140807
推荐阅读
相关标签
  

闽ICP备14008679号