我一直收到此错误:
TypeError: 'encoding' is an invalid keyword argument for this function.
运行代码时:
import re
f = open("/home/file/abc.sql", 'rt', encoding='latin-1')
source=f.read()
with open("/home/file/samp0l9.sql","w") as output:
output.write(re.sub(r'(TBLPROPERTIES \(.*?\))', r'\1;', f, flags=re.DOTALL))
关于为什么会这样的任何想法?文件内只有一些文本。
答案 0 :(得分:0)
Python 3
open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
对比:
Python 2.7
open(name[, mode[, buffering]])