
工作问题集
南山酒肆
路漫漫其修远兮
展开
-
linux替换json某个key的值
1. 概述开发过程中我们经常会遇到需要更改json文件中某个key的值的问题。此处介绍使用jq来更改key的value,非常简洁强大。2. 首先创建一个json文件内容如下root@mgt01:~/csf# cat test.json | jq .{ "num1": "a", "num2": "b"}3.将num1的value改为Aroot@mgt01:~/csf# cat test.json | jq '.num1="A"'{ "num1": "A", "num2": "原创 2021-10-18 16:16:53 · 2784 阅读 · 0 评论 -
ppstgres数据库大小查询
1.查询单个表的大小select pg_size_pretty(pg_relation_size(‘表名’));2.列出所有表的大小SELECT table_schema || ‘.’ || table_name AS table_full_name, pg_size_pretty(pg_total_relation_size(’"’ || table_schema || ‘"."’ || table_name || ‘"’)) AS sizeFROM information_schema.tabl原创 2021-10-15 10:54:28 · 227 阅读 · 0 评论 -
UnicodeDecodeError: ‘ascii‘ codec can‘t decode...
问题描述将str类型的keyvalue,执行keyvalue.decode()UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 5587: ordinal not in range(128)原因:python的str默认是ascii编码,和unicode编码冲突。解决方法:# 导入sys模块import sys# 重新加载sys模块reload(sys)# 设置编码格式为utf-8sys.set原创 2020-09-03 23:34:52 · 542 阅读 · 0 评论