public boolean onTouchEvent(MotionEvent event)
{
if(event.getAction() == MotionEvent.ACTION_OUTSIDE){
System.out.println("dismiss dialog");
this.dismiss();
}
return false;
}
显示
TypeError Traceback(最近一次调用 最后)in() 1个导入编解码器 ----> 2打开(文件名+' .txt',' a +',encoding =' utf-8')为f: 3 for list_of_tweets中的推文: 4打印(tweet.text.replace(' \ r','')。替换(' \ n','') +' |') 5 f.write(tweet.text.replace(' \ r','')。替换(' \ n','' ;)+' |&#39)
TypeError:'编码'是此函数的无效关键字参数
答案 0 :(得分:4)
如果您使用的是python 2,请尝试:
import codecs
from io import open
with open(filename+'.txt', 'a+', encoding='utf-8') as f:
for tweet in list_of_tweets:
print(tweet.text.replace('\r','').replace('\n','')+'|')
f.write(tweet.text.replace('\r','').replace('\n','')+'|')
通常打开python2不接受编码。