码迷,mamicode.com
首页 > 其他好文 > 详细

数据类型

时间:2019-04-12 15:05:07      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:转换   res   error   col   python   script   nbsp   port   imp   

 

1.JavaScript将对象转换成字符串

li = [1,2,3,4]
(4) [1, 2, 3, 4]
JSON.stringify(li)
"[1,2,3,4]"

2.JavaScript将字符串转换成对象
s = JSON.stringify(li)
"[1,2,3,4]"
JSON.parse(s)
(4) [1, 2, 3, 4]

3.python3字段转换成字符串

import json
ret = {status: True, error: None, data: 111}
#字典转换成字符串
result = json.dumps(ret)
print(result)
print(type(result))
‘‘‘
输出:
{"status": true, "error": null, "data": "111"}
<class ‘str‘>
‘‘‘

 

数据类型

标签:转换   res   error   col   python   script   nbsp   port   imp   

原文地址:https://www.cnblogs.com/caoqh/p/10695964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!