【发布时间】:2012-02-20 12:39:13
【问题描述】:
我正在使用lxml 从网页中获取字符串。我该怎么做才能获取我提取的数据字符串而不会出现以下错误?我想我只是无法使用str() 来解决问题。
在python中:
mystring = MySQLdb.escape_string(i.text_content())
(<type 'exceptions.UnicodeEncodeError'>, UnicodeEncodeError('ascii', u"\n\nEve Pownall\n\n \n \n \n \n Eve Pownall\n\t (Author)\n\t\n \u203a Visit Amazon's Eve Pownall Page\n Find all the books, read about the author, and more.\n\n See search results for this author \n Are you an author?\n Learn about Author Central\n \n \n \n \n\n \n amznJQ.onReady('bylinePopover', function () {});\n \n\n\n (Author)\n\n\n\n\n\n\n\n\n\n\n", 75, 76, 'ordinal not in range(128)'), <traceback object at 0x7f225c99f050>)
【问题讨论】: