基于python的景点查询系统


import requests
import json
url = 'http://api.map.baidu.com/telematics/v3/travel_attractions?id=yiheyuan&ak=TueGDhCvwI6fOrQnLM0qmXxY9N0OkOiQ&output=json'
rs = requests.get(url)
rs_dict = json.loads(rs.text)
error_code = rs_dict['error']
if error_code == 0:
    date = rs_dict['date']
    result = rs_dict['result']
    name = result['name']
    telephone = result['telephone']
    star = result['star']
    abstract = result['abstract']
    description = result['description']
    print('日期:%s\n景点名称:%s\n电话:%s\n星级:%s\n景点概括:%s\n景点介绍:%s\n'%(date,name,telephone,star,abstract,description))
    ticket_info = result['ticket_info']
    price = ticket_info['price']
    open_time = ticket_info['open_time']
    print('门票价格:%s\n\n开放时间:%s\n'%(price,open_time))
    attention = ticket_info['attention']
    detail_dict = attention[0]
    name = detail_dict['name']
    description = detail_dict['description']
    print('优惠:%s\n优惠要求:%s\n'%(name,description))
else:
    print('未查询到任何信息')
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值