|
|
TypeError: 'encoding' is an invalid keyword argument for this function今天测试自己的网站get一些参数:发现有问题报错: with open('./bbs168x.html','w',encoding='utf-8') as fp:
( `: p1 s4 w$ e1 l! ?# }- V5 gTypeError: 'encoding' is an invalid keyword argument for this function& c @9 j5 k; M
原始代码:with open('./bbs168x.html','w',encoding='utf-8') as fp:
" t7 U1 @( D# C9 a fp.write(page_text)" Z& D! o( |) K+ U% a9 L; p- a& W Z( H
解决办法:0 \* L- h0 W4 n% t& ]
修改代码:import io ###引入io模块
. k( ?. D# P" K4 ^7 y7 ?+ C- I: ufp= io.open('./bbs168x.html',mode='w', encoding='utf-8')
8 x2 v/ X+ j( A$ h2 B' T. G0 S3 v再次执行:读取数据结束!!!Process finished with exit code 02 D9 s8 o H# E8 ~ i, F
|
|