- 博客(4)
- 收藏
- 关注
原创 python字符串转数组
import re line = '''{name:'兰州',name:'张掖', geoCoord:[103.73, 36.03]},''' city = re.findall("name:'(\w+)'",line) code = re.findall("\[\d+.\d+,\s\d+.\d+\]", line) # code = re.findall("Coord:\[(\d+.\d+)...
2020-04-15 22:06:25 618
原创 python图搜索深度优先和广度优先的自我理解
def search_graph(network, start): need_check = [start] expansion = [] while need_check: person = need_check.pop(-1) # -1 为深度优先 0 为广度优先 if person in expansion: continue ...
2020-04-15 21:48:45 150
原创 python图结构展示
import networkx as nx import matplotlib.pyplot as plt from pylab import mpl social_network = {'小张': ['老王', '小刘', '小西'], '小西': ['张三','李四','陈八'], '陈八':['小七', '王五']} mpl.rcParams['font.sans-serif'] = [...
2020-04-13 22:28:04 288
原创 python统计单词出现的次数
from collections import Counter text = 'hello world hello world hello hello world hello world' print(Counter(text.split()) 一些Counter常用的方法 | Counter() | | Note: If a count is set to zer...
2020-04-04 12:37:49 1452 2
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人