首先,忏悔 - 我不是开发者。我的开发人员刚刚离开,我们需要的一段代码失败,所以我真的希望有人能指出如何解决。本质上,代码查询一个gmail帐户,从特定格式的电子邮件中提取数据并将其传送到一个csv文件中。我认为这是gmail数据中的一个流氓角色。我的问题是如何识别哪个电子邮件包含流氓角色?我缩小了日期范围,因此知道这个问题存在于250条记录中,但我无法直观地识别哪一条。Python - 失败u202c
这里是失败消息:
Authentication successful.
Messages total: 257
Traceback (most recent call last):
File "./extract_billing_from_gmail.py", line 579, in <module>
csvwriter.writerow([ lead_customer, lead['client_id'], lead['operator_name'], lead['chat_id'], lead['time'], lead['date'], email_time, email_date, timelag_minutes, lead['out_of_hours'], lead['type'], lead['area_to_rent_or_buy'], lead['area_to_sell_or_let'], lead['name'], lead['email'], lead['phone'], lead['phone2'], email_subject_plaintext ])
UnicodeEncodeError: 'ascii' codec can't encode character u'\u202c' in position 15: ordinal not in range(128)
Admins-MacBook-Pro:OCSL_created_gmail_billing andy$
每封电子邮件是按以下格式: 主题 - Yomdel带电导线 - [客户名称]
然后身体包含以下内容:
运营商名称:简
主管:奥利弗
客户端ID:XXXXX詹姆斯
时间:上午10时41
日期:20-01-2016
聊天ID:O1Q86YL8T3
名称:苏菲XXXXX
电话:07917 000000
Email:[email protected]
客户类型:买方/卖方
房产类型:3床(买)
预算:£325000
在此之后有几行来描述的要求。
非常感谢您的帮助提前。
你能发布你正在运行的代码吗? –
[U + 202C](http://www.fileformat.info/info/unicode/char/202c/)是双向控件。您的代码可能不准备应付希伯来语/阿拉伯文输入(或者实际上非英文文本)。无法访问代码,我们只能指向http://nedbatchelder.com/text/unipain.html – tripleee