python
GISer_流浪
来自GIS专业的三流程序猿
展开
-
python 解析json字符串报错
使用json.loads() 函数解析json字符串报错 json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 3 (char 2) import json str = '''[{'type': 'O3', 'value': 3, 'collectTime': '', 'tag': ''}''' json.load(str) # 报错 解决办法 pip install原创 2020-06-02 16:25:57 · 709 阅读 · 0 评论 -
python自定义排序
标题使用functools模块中的cmp_to_key函数自定义排序 import functools def cmp(a, b): if b < a: return -1 if a < b: return 1 return 0 a = [1, 2, 5, 4] print(sorted(a, key=functools.cmp_...原创 2020-04-12 23:19:19 · 473 阅读 · 0 评论 -
python内置库--排列组合
from itertools import permutations, combinations res = permutations(range(3), 2) print(list(res)) # (0,1), (0,2), (1,0), (1,2), (2,0), (2,1) res = permutations([0,0,1,1], 2) print(set(list(res))) re...原创 2020-04-12 22:45:11 · 1133 阅读 · 0 评论