- 帖子
- 4
- 精华
- 0
- 积分
- 86
- 阅读权限
- 20
- 注册时间
- 2016-5-4
- 最后登录
- 2016-11-3
|
crossin先生 发表于 2016-11-2 16:17
Two possible reasons
1. You read file, replaced ½, but not save it back or to another file.
2. ½ i ...
你好,crossin先生,我是python菜鸟,有点没明白把那个utf8加到哪,能帮忙改下吗?以下是我代码,谢谢啦。
import os
with open(r'D:\OA\OAText\mysql_10.sql', 'r') as infile,open(r'D:\OA\OAText\mysql_N10.sql', 'w') as outfile:
data = infile.read()
data = data.replace("13½", "13")
data = data.replace("½", "")
data = data.replace("13½ Elm Street", "13 Elm Street")
outfile.write(data)
infile.close()
outfile.close()
os.remove('D:\OA\OAText\mysql_10.sql')
os.rename(r'D:\OA\OAText\mysql_N10.sql',r'D:\OA\OAText\mysql_10.sql')
万分感谢啊 |
|