python写程序

发布网友 发布时间:2022-04-24 13:29

我来回答

1个回答

热心网友 时间:2023-10-14 11:53

#coding=utf-8
#python 2
d = {}
for line in open('b.txt'):
a = line.decode('gbk').rstrip('\n').split(' ')
d[a[0]]=a[1]

for line in open('a.txt'):
st = u' '
line = line.strip('\n')
for c in line.decode('gbk'):
try:
st += d[c]
except:
break
else:
with open('c.txt','a+') as f:
f.write(line+st.encode('gbk')+'\n')
continue
with open('d.txt','a+') as f:
f.write(line+'\n')
else:
print 'OK'

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com