
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 jsonstr = '''[{'type': 'O3', 'value': 3, 'collectTime': '', 'tag': ''}'''json.load(str)# 报错解决办法pip install原创 2020-06-02 16:25:57 · 910 阅读 · 0 评论 -
python自定义排序
标题使用functools模块中的cmp_to_key函数自定义排序import functoolsdef cmp(a, b): if b < a: return -1 if a < b: return 1 return 0a = [1, 2, 5, 4]print(sorted(a, key=functools.cmp_...原创 2020-04-12 23:19:19 · 526 阅读 · 0 评论 -
python内置库--排列组合
from itertools import permutations, combinationsres = 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 · 1191 阅读 · 0 评论