Eclipse中java代码调用python脚本时提示错误Exception in thread "main" Traceback (most recent call last):,请问如何解决?

weixin_38066147 2017-03-02 01:22:48
我Eclipse配置了python和jython了,Eclipse中java代码调用python脚本时提示错误Exception in thread "main" Traceback (most recent call last): java代码如下: package test; import org.python.util.PythonInterpreter; public class ThirdJavaScript { public static void main(String args[]) { PythonInterpreter interpreter = new PythonInterpreter(); interpreter.execfile("E:\\python\\python_demo\\see_xiaohua.py"); } } 原有python脚本代码如下: # coding:utf-8 #!/usr/bin/python import urllib2#与下面脚本对比没有被注释 import re#与下面脚本对比没有被注释 from bs4 import BeautifulSoup#与下面脚本对比没有被注释 number =0 #定义序号变量 page = raw_input("Please input page:") user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = { 'User-Agent' : user_agent } request = urllib2.Request('http://www.qiushibaike.com/hot/page/'+str(page)+'/?s=4915651',headers = headers) response = urllib2.urlopen(request) html = response.read() #获取页面源码 soup = BeautifulSoup(html,"html.parser") items = soup.find_all('div',attrs={"class":"content"}) #搜索div标签并且同时含有class=content内容 for item in items: number +=1 pattern = re.compile('<span>(.*?)</span>',re.S) lists = re.findall(pattern,str(item)) for list in lists: print 'NO',number,':',list.decode('utf-8'),'\n' print "End..." 运行时,控制台出现如下错误,请问如何修改?  
...全文
174 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复

472

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧