请问python怎么调用这个api ?

python怎么调用这个api http://apistore.baidu.com/astore/serviceinfo/27469.html


至尊宝的传说
浏览 900回答 3
3回答

四季花海

创建一个html后缀的文件,然后利用文件操作的相关知识写入文件,完成后,可以直接打开file.html查看。和你的思路能对上,你可以读取数据库内容,然后格式成html规范,写入file.html文件。完成后,就可以打开file.html查看你的结果。以下是我写的代码,你参考下:(代码相对来说比较简单,这只是给你一个思路,具体你可以依据这个方向进行修改完善)python3.6环境123456789#&nbsp;该代码运行于至少python3.6支持#&nbsp;功能:把内容保存为html格式文件with&nbsp;open('file.html','w')&nbsp;as&nbsp;file:&nbsp;#以w的模式打开file.html文件,不存在就新建&nbsp;&nbsp;&nbsp;&nbsp;file.write('<html><body><table&nbsp;border=1><tr><th>a列表</th><th>b列表</th></tr><indent>输出结果:')&nbsp;#使用write写入字符串内容到file.html&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;i&nbsp;in&nbsp;range(10):#执行一个遍历操作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a=i&nbsp;#i依次赋值给a,i内容为0,1,2,3,4,5,6,7,8,9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b=i**2&nbsp;#把i的值依次进行i的2次幂操作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file.write("<tr><td>"f'{a}'"</td><td>"f'{b}'"</td></tr>")&nbsp;#使用write写入字符串内容到file.html&nbsp;&nbsp;&nbsp;&nbsp;file.write('</indent></table></body></html>')&nbsp;#使用write写入字符串内容到file.htmlpython3环境123456789#&nbsp;该代码运行于python3#&nbsp;功能:把内容保存为html格式文件with&nbsp;open('file.html','w')&nbsp;as&nbsp;file:&nbsp;#以w的模式打开file.html文件,不存在就新建&nbsp;&nbsp;&nbsp;&nbsp;file.write('<html><body><table&nbsp;border=1><tr><th>a列表</th><th>b列表</th></tr><indent>输出结果:')&nbsp;#使用write写入字符串内容到file.html&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;i&nbsp;in&nbsp;range(10):#执行一个遍历操作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a=i&nbsp;#i依次赋值给a,i内容为0,1,2,3,4,5,6,7,8,9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b=i**2&nbsp;#把i的值依次进行i的2次幂操作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file.write('<tr><td>{}'.format(a)+'</td><td>{}'.format(b)+'</td></tr>')&nbsp;#使用write写入字符串内容到file.html&nbsp;&nbsp;&nbsp;&nbsp;file.write('</indent></table></body></html>')&nbsp;#使用write写入字符串内容到file.html

慕仙森

具体的原因也不太清楚,不过可以逐步排查:网页那边,F12看看ajax发送的请求表单里,所有字段内容是否正确python的server那边,从收到数据开始 print 相关的变量逐个看看是否符合预期如果是flask一类的框架,可以设个断点检查上下文的变量如果还是不行,那就再把逻辑简化一下,看看能不能重现问题。
打开App,查看更多内容
随时随地看视频慕课网APP