python学习笔记
日常学习记录
篮砂石
正在学习NLP,深度学习,社区发现,节点重要性,图神经网络, node embedding
展开
-
(python)将字典按value排序后变为列表
ksE是字典ksE = {'a':3,'b':2,'c':5}t = sorted([(v, k) for k, v in ksE.items()],reverse=True)原创 2021-10-24 17:56:31 · 1251 阅读 · 2 评论 -
安装特定版本的python包
用==版本号:pip install numpy==1.14.0原创 2021-10-20 18:11:24 · 457 阅读 · 0 评论 -
两列表同时排序,排序后对应元素不变(用到zip打包和解包)
连接:1. 两个列表同时排序2.*和**的作用原创 2021-10-13 21:17:08 · 150 阅读 · 0 评论 -
python删除字符串左右两边的多个符号
引号中加入删除符号的列表n.strip('[{}\n]')原创 2021-09-15 16:15:57 · 2764 阅读 · 0 评论 -
Python 字典,统计value相同的key(用到了字典中,有k对应的集合,把v加入;没有这个k,创建k)
info = {"a":1,"b":1,"c":2}res = {}for i in info: if info2[i] > 1: res.setdefault(info[i],set()).add(i)原创 2021-09-13 11:28:38 · 1374 阅读 · 0 评论 -
DataFrame添加列名,查看均值等,seaborn
查看数据seaborn画图简单好看(看两两特征的关系,对角线是自己和自己)dropna()处理缺失值原创 2021-06-22 09:33:31 · 166 阅读 · 0 评论 -
python 文件夹操作(获取当前路径,新建文件夹,判断文件是否存在)
获取当前路径import ospath = os.getcwd()新建文件夹path = path+"/uploads"if not os.path.exists(path1): os.makedirs(path1)原创 2021-06-19 10:14:37 · 1386 阅读 · 0 评论 -
python的格式化输出
在print中加入f参数,变量放入{}name = "张三"score = 99print(f"{name}同学的成绩是:{score}")原创 2021-06-07 18:00:55 · 73 阅读 · 0 评论 -
(Python编程)Assignment 1 COMP9021, Term 1, 2021,渐开螺旋矩阵,骰子
一.题目Consider the board below, which can be imagined as being infinite, so only a small part is represented. A die is placed on cell number 1 of the board in the position indicated: 3 at the top, 2 at the front (towards cell number 4 of the board), and 1原创 2021-05-27 10:42:53 · 773 阅读 · 0 评论 -
python 编程常用函数(持续更新)
from numpy import *a= list(range(10))random.shuffle(a)print(a)原创 2021-02-20 11:45:16 · 179 阅读 · 0 评论 -
c++类实现 快速、冒泡、堆排序(递归非递归)
#include <iostream>#include <stack>using namespace std;class Sort{private: int a[10];public: void setA(); void getA(); //冒泡排序 void bubble_sort(); //冒泡递归 void bubble_rec(int length); //快速排序递归算法 void quick_sort(int low,int high);.原创 2020-10-22 17:05:02 · 388 阅读 · 0 评论 -
python中sorted方法排序字典时关于sortedClassCount[0][0]的注意事项
用sorted排序字典时返回的是又元组组成的列表import operatora={}a["red"]=30a["yellow"]=15a['black']=12b = sorted(a.items(),key=operator.itemgetter(1),reverse=True)print(b)b[0][0]运行结果:所以b[0][0]可以输出类别原创 2020-08-15 10:11:39 · 1369 阅读 · 0 评论 -
jupyter notebook绘制cos,sin图像 加入%matplotlib inline解决Figure size 640x480 with 1 Axes问题
import numpy as npimport matplotlib.pyplot as plt%matplotlib inline #解决Figure size 640x480 with 1 Axes问题x=np.arange(0,6,0.1)y1=np.sin(x)y2=np.cos(x)plt.plot(x,y1,label="sin")plt.plot(x,y2,linestyle="--",label="cos")plt.xlabel="x"plt.ylabel="y.原创 2020-07-16 09:33:43 · 2846 阅读 · 0 评论 -
倒排索引讲的较细的文章
文章链接:https://www.cnblogs.com/zlslch/p/6440114.html原创 2020-04-17 17:00:00 · 134 阅读 · 0 评论