用PyQt-WebVi从Python的HTML字符串中提取数据

2024-10-01 15:34:02 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我使用googlemapsapi来计算地图上两点之间的直线距离。在

gmaps="""
***generic google maps HTML api stuff first, then:***

overalldist=calcDistance(firstcoord, secondcoord);
alert(overalldist)

//calculates distance between two points in km's
function calcDistance(firstcoord, secondcoord) {
      return (google.maps.geometry.spherical.computeDistanceBetween(firstcoord, secondcoord) / 1000).toFixed(2);
"""

我的所有代码都放在一个简单的字符串中。 字符串由以下对象调用:

^{pr2}$

其中gmaps是包含HTML的字符串名,webView是PyQt GUI中HTML查看器的名称。在

结果是一个弹出框,输出正确的距离。在

我的问题是我不能从HTML中提取变量'overalldist'。警报弹出并显示正确的距离,但我无法将其移动到Python代码中。在

请告知。在

有什么进一步的想法吗?在

我试图从HTML代码中检索calcDistance函数,以便在Python代码中使用。在

颠簸 颠簸


Tags: 字符串代码距离htmlgoogle地图generic直线

热门问题