小编Car*_*ary的帖子

谷歌地图响应以“b”开头,如何检索数据?

我试图从谷歌地图请求中获取一些数据;它返回了以下数据。它以某种方式以 'b' 字符开头:

b'{
    \n "destination_addresses" : [ "Toronto, ON, Canada" ],
    \n "origin_addresses" : [ "Ottawa, ON, Canada" ],
    \n "rows" : [\n {
        \n "elements" : [\n {
            \n "distance" : {
                \n "text" : "450 km",
                \n "value" : 449678\n
            },
            \n "duration" : {
                \n "text" : "4 hours 14 mins",
                \n "value" : 15229\n
            },
            \n "status" : "OK"\n
        }\n ]\n
    }\n   ],
    \n   "status" : "OK"\n
}\n'
Run Code Online (Sandbox Code Playgroud)

然后我试图从数据中获取一个值,它因为开头的 'b' 而出错。如果我删除'b',它工作正常:

response = str(urllib.request.urlopen(url).read())
result …
Run Code Online (Sandbox Code Playgroud)

python google-maps

0
推荐指数
1
解决办法
1580
查看次数

标签 统计

google-maps ×1

python ×1