zoukankan      html  css  js  c++  java
  • Python--day72--json内容回顾

    前后端分离,Json格式字符串:序列化和反序列化

     1 """
     2     复习python中的json模块
     3 """
     4 
     5 import json
     6 
     7 s = '{"name":"xiaohei","age":18}'
     8 #把字符串反序列成python中的数据类型
     9 ret = json.loads(s)
    10 print(ret,type(ret))
    11 
    12 #把字典序列化Python中的字符串
    13 ret2 = json.dumps(ret)
    14 print(ret,type(ret2))

    合格的json对象:

    ["one", "two", "three"]
    { "one": 1, "two": 2, "three": 3 }
    {"names": ["张三", "李四"] }
    [ { "name": "张三"}, {"name": "李四"} ] 

     不合格的json对象:

    复制代码
    { name: "张三", 'age': 32 }  // 属性名必须使用双引号
    [32, 64, 128, 0xFFF] // 不能使用十六进制值
    { "name": "张三", "age": undefined }  // 不能使用undefined
    { "name": "张三",
      "birthday": new Date('Fri, 26 Aug 2011 07:13:10 GMT'),
      "getName":  function() {return this.name;}  // 不能使用函数和日期对象
  • 相关阅读:
    无言
    计算机网络的所有课件
    Linux 分区
    Linux 文件管理权限
    DropDownList 控件
    CssClass初步语法了解
    BulletedList用途
    BulletedList项目控件基础CSS基础
    Checkbox与foreach循环
    RadioButton控件
  • 原文地址:https://www.cnblogs.com/xudj/p/10684017.html
Copyright © 2011-2022 走看看