打印输出报错:UnicodeEncodeError
大佬,您好: 我的想法加打印输出到文件,然后通过邮件发送提醒。 打印输出到文件,python weiboSpider >>a.txt报错,请问有好的解决方式吗? 如果能直接加入邮件提醒功能是最好的。 谢谢!
报错信息太长,我只复制了部分。
('Error: ', UnicodeEncodeError('ascii', u'\u7528\u6237\u6635\u79f0: 360CERT', 0, 4, 'ordinal not in range(128)')) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError("'NoneType' object has no attribute 'getitem'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError("'NoneType' object has no attribute 'getitem'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError("'NoneType' object has no attribute 'getitem'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError("'NoneType' object has no attribute 'getitem'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError("'NoneType' object has no attribute 'getitem'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError("'NoneType' object has no attribute 'getitem'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError("'NoneType' object has no attribute 'getitem'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError("'NoneType' object has no attribute 'getitem'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError("'NoneType' object has no attribute 'getitem'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'split'",)) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",)) ('Error: ', TypeError("'NoneType' object has no attribute 'getitem'",)) ('Error: ', UnicodeEncodeError('ascii', u'------------------------------\u5df2\u83b7\u53d6360CERT(6308459892)\u7684\u7b2c1\u9875\u5fae\u535a------------------------------', 30, 33, 'ordinal not in range(128)')) ('Error: ', TypeError('encode() argument 1 must be string, not None',)) ('Error: ', AttributeError("'NoneType' object has no attribute 'rfind'",))
感谢反馈。
建议使用python3,python2有这个错误,python3可以正确输出到txt文件
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closing as stale, please reopen if you'd like to work on this further.