AJAX

一 AJAX预备知识:json进阶

1.1 什么是JSON?

JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。JSON是用字符串来表示Javascript对象;

记住:json字符串就是js对象的一种表现形式(字符串的形式)

既然我们已经学过python的json模块,我们就用它来测试下json字符串和json对象到底是什么

import json
i=10
s='hello'
t=(1,4,6)
l=[3,5,7]
d={'name':"yuan"}

json_str1=json.dumps(i)
json_str2=json.dumps(s)
json_str3=json.dumps(t)
json_str4=json.dumps(l)
json_str5=json.dumps(d)

print(json_str1)   #'10'
print(json_str2)   #'"hello"'
print(json_str3)   #'[1, 4, 6]'
print(json_str4)   #'[3, 5, 7]'
print(json_str5)   #'{"name": "liu"}'
View Code

相关文章:

  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
相关资源
相似解决方案