zoukankan      html  css  js  c++  java
  • python接口自动化5-Json数据处理

    #####################################

    1.首先说下为什么要encode,python里面bool值是True和False,json里面bool值是true和false,并且区分大小写,这就尴尬了,明明都是bool值。
    在python里面写的代码,传到json里,肯定识别不了,所以需要把python的代码经过encode后成为json可识别的数据类型。
    2.举个简单例子,下图中dict类型经过json.dumps()后变成str,True变成了true,False变成了fasle


    ######################################

            updatetheme = {
                "data": {
                    "type": "threads",
                    "attributes": {
                        "isApproved": 1,
                        "isSticky": True,
                        "isEssence": True,
                        "isDeleted": False,
                        "isFavorite": True
                    }
                },
                "relationships": {
                    "category": {
                        "data": {
                            "type": "categories",
                            "id": "3"
                        }
                    }
                }
            }
            import json
            print(updatetheme)
            #
            updatetheme = json.dumps(updatetheme)
            print(updatetheme)

    ###############################################

    ########################################

  • 相关阅读:
    访存模型
    Petri网
    Forward secrecy
    TensorFlow训练神经网络cost一直为0
    解决tensorflow在训练的时候权重是nan问题
    tf.argmax
    Keras教程
    z-score
    隐马尔可夫(HMM)、前/后向算法、Viterbi算法
    受限玻尔兹曼机基础教程
  • 原文地址:https://www.cnblogs.com/andy0816/p/12822696.html
Copyright © 2011-2022 走看看