- python的 dict 类型 在node里 怎么和字符串类型互相转换 我数据库全部是dict的字符串 下面为python源码 a = "{'Di_time': '2019-05-02 17:49:59', 'Di_now': {'Time': '2019-05-02T09:50:00.000Z', 'Open': 0.3013, 'High': 0.3013, 'Low': 0.3013, 'Close': 0.3013, 'Vol': 0}, 'Di_past': {'Time': '2019-05-02T09:49:00.000Z', 'Open': 0.3013, 'High': 0.3013, 'Low': 0.3013, 'Close': 0.3013, 'Vol': 67}, 'Di_depth': {'S_jia1': '0.3013'}}" print('类型',type(a),a)
a = eval(a) #字符串 转 字典 print('类型',type(a),a) print(a['Di_now']['Time']) #调用字典
a = str(a) #字典 转 字符串 print('类型',type(a),a)
- 我的数据库是mariadb 测试了几个模块 发现只有 mysql2能用不报错 和mysql模块语法通用 但是我测试了几个封装成方法 取返回值 返回值都有问题 下面是我理想的状态 但是不能用 function read () { connection.query( //查询所有表名称 'show tables', function (error, results, fields) { console.log('错误',error) // error 错误信息 console.log('返回',results) // results 返回值 //console.log('字段',fields) // fields 字段信息 }); return results }