python
rewqaqa
坚持!
展开
-
pip镜像安装
pip镜像安装原创 2023-03-14 13:56:37 · 184 阅读 · 0 评论 -
python-社交网络数据处理
边表node值非连续改为连续import networkx as nxdef updateFile(file,old_str,new_str): file_data = "" with open(file, "r", encoding="utf-8") as f: for line in f: if old_str in line: line = line.replace(old_str,new_str)原创 2021-08-08 17:23:08 · 500 阅读 · 0 评论 -
python边表转邻接表
import numpy as npft = open("figure.txt", "r")b = {}lines = ft.readlines()for line in lines: a = list(line.rstrip().split("\t")) if a[0] in list(b.keys()): if a[1] not in b[a[0]]: b[a[0]].append(a[1]) else:原创 2021-05-30 13:12:53 · 318 阅读 · 0 评论 -
numpy转换网络数据格式
现有的数据格式:1 2 4 53 4目标格式:0 0 0 0 0 00 0 1 0 0 00 1 0 0 0 00 0 0 0 1 00 0 0 1 0 10 0 0 0 1 0代码:import numpy as npb = np.zeros((6, 6))ft = open("kk.txt", "r")lines = ft.readlines()for line in lines: a = list(line.rstrip().split(" "))原创 2021-01-16 18:24:07 · 177 阅读 · 0 评论