Jython ValueError:chr()arg不在范围内(256)

时间:2018-12-09 07:45:32

标签: jython jython-2.7

我正在使用Jython(jython2.7.0)将字符串值从Java程序发送到python方法,然后将该值返回给Java程序,但出现此错误。 ValueError: chr() arg not in range(256)您知道问题的原因是什么,如何解决?

Exception in thread "main" Traceback (most recent call last):
  File "PageRanking.py", line 9, in <module>
    from bs4 import BeautifulSoup  
  File "C:\jython2.7.0\Lib\bs4\__init__.py", line 35, in <module>
    from .builder import builder_registry, ParserRejectedMarkup
  File "C:\jython2.7.0\Lib\bs4\builder\__init__.py", line 7, in <module>
    from bs4.element import (
  File "C:\jython2.7.0\Lib\bs4\element.py", line 10, in <module>
    from bs4.dammit import EntitySubstitution
  File "C:\jython2.7.0\Lib\bs4\dammit.py", line 14, in <module>
    from html.entities import codepoint2name
  File "C:\jython2.7.0\Lib\html\__init__.py", line 6, in <module>
    from html.entities import html5 as _html5
  File "C:\jython2.7.0\Lib\html\entities.py", line 2507, in <module>
    entitydefs[name] = chr(codepoint)

这是我的Python代码

from __future__ import with_statement

from bs4 import BeautifulSoup  
    import requests

def pageRank(link):
    url = "https://checkpagerank.net/"

payload = {'name':link} 
r = requests.post(url, payload)
with open("requests_results.html", "wb") as f:
    f.write(r.content)

with open(r'requests_results.html', "r", encoding='utf-8') as f:
    text= f.read()


soup = BeautifulSoup(r.text, 'html.parser')  

results = soup.find_all('h2')


SResult = results[1]

first= SResult.contents[0]
rankerName = first.find('b').text

second= SResult.contents[2]
rankervalue = second.find('b').text

x = rankervalue[:1]
x = int(x)
x= x*100/10

return x

0 个答案:

没有答案