04 2022 档案
摘要:点击查看代码 # reshape用法 # numpy.arange(n).reshape(a,b)依次生成n个自然数,并且以a行b列的数组形式显示 import numpy as np array = np.arange(16).reshape(2, 8) print(array) # output
阅读全文
摘要:https://www.runoob.com/python/python-func-zip.html
阅读全文
摘要:Python map() 函数 | 菜鸟教程 (runoob.com)
阅读全文
摘要:https://www.runoob.com/python/python-func-reduce.html
阅读全文
摘要:set集合《python中文指南》P66
阅读全文
摘要:dict字典《python中文指南》P62
阅读全文
摘要:tuple元组《python中文指南》P59
阅读全文
摘要:list列表《python中文指南》P54
阅读全文
摘要:在字符串中,使用 {} 进行占位,然后在字符串后跟上 .format() 函数,这个函数的参数就是我们要往字符串中填充的变量。 format 函数会依次填充,比如第一个 {} 会取到第一个参数 name,第二个 {} 会取到第二个参数age
阅读全文
摘要:startswith() 判断字符串是否以某字符串开头 endswith() 判断字符串是否以某字符串结尾
阅读全文
摘要:去掉首尾空格 lstrip() 去除左边空格 rstrip() 去除右边空格 strip() 去除左右两边空格
阅读全文
摘要:https://blog.csdn.net/AnneQiQi/article/details/64125186?ops_request_misc=&request_id=&biz_id=102&utm_term=python%20scatter()%E5%87%BD%E6%95%B0&utm_med
阅读全文
摘要:点击查看代码 # subplot创建单个子图 # subplot(nrows, ncols, sharex, sharey, subplot_kw, **fig_kw) # nrows : subplot的行数 # ncols : subplot的列数 # sharex : 所有subplot应该使
阅读全文
摘要:点击查看代码 # figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True) # num:图像编号或名称,数字为编号,字符串为名称 # figsize:指定figure的宽和高,单位为英
阅读全文
摘要:点击查看代码 # s.strip(ch) 将字符串头和尾的指定字符ch去掉,如果这里去掉一个之后还是有ch,则继续去掉,直到没有;ch不填,则默认ch=空格 s1 = " a a ab a a ab" s2 = "a a ab" s3 = "aa ab" s4 = "a b ba" print(s1
阅读全文
摘要:点击查看代码 # np.zeros() # 返回来一个给定形状和类型的用0填充的数组; # zeros(shape, dtype=float, order=‘C’) # shape:形状 # dtype:数据类型,可选参数,默认numpy.float64 # order:可选参数,C:行优先;F:代
阅读全文
摘要:点击查看代码 # sorted(iterable, cmp=None, key=None, reverse=False) # iterable -- 可迭代对象。 # cmp -- 比较的函数,这个具有两个参数,参数的值都是从可迭代对象中取出,此函数必须遵守的规则为,大于则返回1,小于则返回-1,等
阅读全文
摘要:点击查看代码 # dict_name.get(key, default=None), # 字典的get()方法,返回指定键的值。如果不存在key,则字典中返回默认值"default"中的值 # default: 要返回key的值,可以是任何值,如整形、字符串、列表、字典等 dict = {'A':
阅读全文
摘要:点击查看代码 # argsort() 对数组升序排列,但输出的是原数组下标,不是排序好的数组 # argsort()[num] # 当num >= 0时,argsort()[num]的值即为y[num]的值 # 当num < 0时,argsort()[num]的值为y数组反向输出的第num个数 im
阅读全文
摘要:点击查看代码 # 当axis=0,就是将一个矩阵的每一列向量相加 # 当axis=1,就是将一个矩阵的每一行向量相加 # 当没有axis时,只是单纯地将所有元素相加 import numpy as np A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # print(np
阅读全文
摘要:点击查看代码 # python tile() 函数简单介绍 # # 格式:tile(A,reps) # * A:array_like 输入的array # * reps:array_like A沿各个维度重复的次数 import numpy as np A = [1, 2] B = [[1, 2,
阅读全文
摘要:点击查看代码 import numpy as np a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) print(a.shape[0]) # 读取行数 4 print(a.shape[1]) # 读取列数 3 print(a.
阅读全文
摘要:位运算就是直接对整数在内存中的二进制位进行操作 and运算 & 一个数 and 1的结果就是取二进制的最末位。这可以用来判断一个整数的奇偶,二进制的最末位为0表示该数为偶数,最末位为1表示该数为奇数。 相同位的两个数字都为1,则为1;若有一个不为1,则为0。 or运算 | 相同位只要一个为1即为1。
阅读全文
摘要:一维数组 点击查看代码 #include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int>a; int temp=0; for(int i=0;i<n;i++){ cin >> temp; a.p
阅读全文
摘要:break用法 点击查看代码 #include<stdio.h> int main(){ int type; scanf("%d",&type); switch(type){ case 1: printf("操作1"); // break; //只删除这个case:1的break。 假如输入:1,会
阅读全文
摘要:点击查看代码 //辗转相除法 /* 输入a,b 如果b等于0,计算结束,a就是最大公约数; 否则,计算a除以b的余数,让a等于b,而b等于那个余数; 回到第一步。 */ #include<stdio.h> int main(){ int a,b; printf("Please enter your
阅读全文