get LookupError:未知编码:ascii

时间:2016-02-15 19:13:00

标签: python python-2.7 python-3.x ascii wolframalpha

我几乎可以让wolframalpha运行,但是我坚持这个错误: 我工作2天以后现在一切正常但是这个错误来了

    texts = texts.encode('ascii’, ‘ignore')
LookupError: unknown encoding: ascii’, ‘ignore

我的代码是

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import wolframalpha
import sys


app_id='PR5756-H3EP749GGH'                                              

client = wolframalpha.Client(app_id)

query = ' '.join(sys.argv[1:])
res = client.query(query)

if len(res.pods) > 0:
  texts = ""
pod = res.pods[1]
if pod.text:
 texts = pod.text
else:
 texts = "I have no answer for that"
# to skip ascii character in case of error
texts = texts.encode('ascii’, ‘ignore')
print ('texts')

请帮助

1 个答案:

答案 0 :(得分:1)

您的引号字符不匹配,您使用的是两种不同类型的引号'

texts = texts.encode('ascii', 'ignore')