美文网首页
项目问题总结(2018-10-09)

项目问题总结(2018-10-09)

作者: sunshaoping | 来源:发表于2018-10-09 13:50 被阅读0次

一、python获取json数据

import urllib.request


def get_exchange_list():
    exchanges_list = json.loads(urllib.request.urlopen('http://q.botvs.net/api/symbols').read())
    return exchanges_list

报错:TypeError: the JSON object must be str, not 'bytes',意思为json对象必须为字符串类型,而不是字节类型

def get_exchange_list():
    exchanges_list = json.loads(urllib.request.urlopen('http://q.botvs.net/api/symbols').read().decode("utf-8"))
    return exchanges_list

问题解决

二、python ping ip

import os,datetime,time

def run():
    ip1 = "www.baidu.com"
    backinfo = os.system("ping -w 1 %s" % ip1)
    if backinfo != 0: 
        with open("app.txt", "a") as f:
            f.write(str(datetime.datetime.now()) + "--" + str(ip1) + "--" + str(backinfo) + "\n")
            f.close()


if __name__ == '__main__':
    while True:
        run()
        time.sleep(60)

相关文章

  • 项目问题总结(2018-10-09)

    一、python获取json数据 报错:TypeError: the JSON object must be st...

  • 树的遍历问题探讨及总结

    树的遍历问题探讨及总结 Create: 2018-10-09 17:34:07 1.知两序求两序 序指的是前序、中...

  • 项目问题总结

    盖士人读书,第一要有志,第二要有识,第三要有恒。有志则断不甘为下流;有识则知学问无穷,不敢以一得自足,如河泊之观海...

  • 项目问题总结

    1.小米手机轮播图下方的指示点无法显示,原因:因为小米手机版本为6.0,指示点资源为V21,应该把drawable...

  • 项目问题总结

    一、scrollview嵌套recyclerview卡顿问题及解决方法二、Listview嵌套gridview单行...

  • 灵感之倩女幽魂写真集

    2018-10-09

  • DView项目问题总结

    DView是一款网管系统,基于Spring Boot开发,Maven构建,主要包含5个模块: Probe:与网络设...

  • iOS项目问题总结

    1.Xcode9打包问题错误一: 错误二: 2.项目运行提示xcode could not write to d...

  • 记录项目问题总结

    本来这种事情是没有我什么事情的,只是因为昨天吐槽的太多,吐槽的我都不知道我在吐槽神马,汪汪汪!上头很无奈的说,明天...

  • 个人项目问题总结

    1.Xcode8上command+/快捷注释失效,解决办法:打开终端,将sudo /usr/libexec/xpc...

网友评论

      本文标题:项目问题总结(2018-10-09)

      本文链接:https://www.haomeiwen.com/subject/cweeaftx.html