有5404英寸”无语言.txt". 示例
...
2mz tomorrow
2night tonight
2nite tonight
soml story of my life
ssry so sorry
...
在“测试.txt““
^{2}$我的代码:
NoSlang = open("noslang.txt")
for line in NoSlang:
slang,fulltext = map(str, line.split('\t'))
dic[slang] = fulltext.strip('\n')
file = open('test.txt').read().split("\n")
for line in file:
sline = line.split(" ")
for n,i in enumerate(sline):
if i in dic:
sline[n] = dic[i]
print ' '.join(sline)
我试着创造一本字典,并把它们替换成测试.txt". 结果也一样,没有什么变化。在
有什么建议吗?在
预期结果:
yeah right
i'll attend the class
tomorrow will be great
可以使用正则表达式替换文件中的单词:
如果
^{pr2}$input.txt
不是很大,可以一次替换所有俚语:像这样:
其中
^{pr2}$noslang.txt
包含:相关问题 更多 >
编程相关推荐