自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(32)
  • 收藏
  • 关注

原创 当 mac遇到module ‘cv2‘ has no attribute ‘bgsegm‘

使用bgsegm一直报错,可以通过安装pip install opencv-contrib-python来解决问题报错当依旧存在报错的情况时检查python版本,若为python3版本应将代码改为bgsubmog = cv2.createBackgroundSubtractorMOG2() #For python3而不是cv2.bgsegm.createBackgroundSubtractorMOG()问题就可以解决了...

2022-05-06 10:23:06 875

原创 针对MAC系统Hadoop集群搭建指南1

Hadoop安装教程_单机/伪分布式配置(厦门大学·数据库实验室)http://dblab.xmu.edu.cn/blog/install-hadoop/Hadoop集群安装教程(厦门大学·数据库实验室)http://dblab.xmu.edu.cn/blog/install-hadoop-cluster/将mac系统的文件传输与virtual box 相关联 可以进行文件的互相交互方法一:可以参考一下的文章https://blog.csdn.net/Yyukiii/article/detai.

2021-06-21 23:42:55 307

原创 Mac如何与virtualbox进行文件共享—图文教程

在Mac的界面上创建一个文件夹将要作为与vir共享的文件夹(创建在任何位置都可以)????我就直接创建在桌面上会比较的方便单机文件夹右键,将文件夹设置为可共享的文件夹????把共享的文件夹勾起来就可以了在virtualbox中打开虚拟机的设置,选择共享文件夹,空白处右键添加共享文件夹。打开后添加路径在后面两个选项☑️打开后在ubuntu终端输入 sudo mount -t vboxsf 共享文件夹名 /mnt(挂载点)就可以在 /mnt 中看到共享的文件了ps:如果刚开始在改属

2021-05-06 23:16:39 3372

原创 Matplotlib数据可视化基础

掌握绘图基础语法与常用参数import matplotlib.pyplot as pltimport numpy as npplt.figure(figsize=(4,4))x = np.arange(10)plt.title('line')plt.plot(x,np.sin(x))plt.plot(x,np.cos(x))plt.legend(['sin','cos'])plt.savefig('./tmp/tmp.png') 先保存在做展示plt.show()import o

2021-01-27 00:29:03 135

原创 numpy数值计算应用

读取iris数据集中的花萼长度数据(已保存为csv格式),并对其进行排序、去重、求和、累积和均值、标准差、方差、最小最大值data=np.loadtxt('.')data.sortnp.unique(data)np.sum(data)np.cumsum(data)print(np.mean(data))#均值print(np.std(data))#标准差print(np.var(data))#方差print(np.min(data))#最小值print(np.max(data)

2021-01-26 23:32:52 157

原创 利用Numpy进行统计分析

numpy文件读写主要有二进制的文件读写和文件列表数据读写save函数是以二进制的格式保存数据(保存一个数组)savez函数可以将多个数组保存到一个文件中load函数是从二进制的文件中读取数据import numpy as npa = np.random.random((3,3))aarray([[0.40535855, 0.10925838, 0.84017846], [0.40896593, 0.48596948, 0.39802654], [0.7502

2021-01-26 23:32:19 457

原创 掌握numpy矩阵与通用函数

import numpy as npnp.array([[1,2],[3,4]])array([[1, 2], [3, 4]])np.mat([[1,2],[3,4]])matrix([[1, 2], [3, 4]])np.matrix([[1,2],[3,4]])matrix([[1, 2], [3, 4]])a=np.mat([[1,2],[3,4]])b=np.matrix([[11,21],[31,41]])np.bma

2021-01-26 22:46:38 161

原创 掌握numpy数组对象ndarray

import numpy as npa=np.array([[1,2,3],[1,2,4]],dtype=np.float32)a.size #查看属性a.shapea.ndima.dtype #优先考虑后面的dtype('float32')a.reshape(3,2) #重建数组array([[1., 2.], [3., 1.], [2., 4.]], dtype=float32)list(range(10))[0, 1, 2, 3, 4

2021-01-22 16:31:26 183

原创 迭代基础学习

list1 = [1,2,3,4]it = iter(list1)it<list_iterator at 0x593d518>next(it)1next(it)2next(it)3next(it)4next(it)---------------------------------------------------------------------------StopIteration

2020-12-31 11:49:29 85

原创 网站建立的初应用

from flask import Flask#定义加实例化app = Flask(__name__)@app.route("/")#指定一个地址(装饰器)用route进入到下面的def函数中def hello(): return "Hello World!\n这是一个web应用程序"if __name__ == '__main__':#真正的去运行程序,如果符合条件就会运行 app.run()#run是方法 * Running on http://127.0.0.1:5000/

2020-12-24 10:01:18 50

原创 运用Tkinter--猜数字游戏

import tkinterimport tkinter.messageboximport randomroot = tkinter.Tk()root.title('猜数字')shuzi=tkinter.StringVar()Label = tkinter.Label(root,text="请输入1到100以内的整数")Label.place(x=20,y=10,width=140,height=40)sg = tkinter.StringVar(root)Entrysg =tkin

2020-12-24 08:44:14 256

原创 Python异常处理实验

try: print('try') r=10/0#除零错误 print('result',r)except ZeroDivisionError as e:#假如上面没有#错误就执行该语句 print('except',e)#获取错误提示finally: print('finally')#无论如何都会执行,同时释放内存tryexcept division by zerofinallytry: print('try') r=10/0exc

2020-12-17 12:03:10 705

原创 运用Tkinter——计算身体质量指数(方法2)

import tkinterimport tkinter.messageboxclass BMI: def __init__(self,height,weight): self.height = float(height) self.weight = float(weight) self.jieguo=self.weight/self.height/self.height if self.jieguo < 18.5 :

2020-12-17 10:06:25 127

原创 运用Tkinter——计算身体质量指数

import tkinterimport tkinter.messagebox#def msgbox():root = tkinter.Tk() #创建Tkbmi = tkinter.StringVar()label=tkinter.Label(root,text="请输入体重")label.place(x=20,y=5,height=30,width=80)label=tkinter.Label(root,text="请输入身高")label.place(x=20,y=35,h

2020-12-13 14:41:30 181

原创 tkinter的初步运用(按钮、文本框的添加)

import tkinterimport tkinter.messageboxdef msgbox(): tkinter.messagebox.showinfo(title="xuehao",message=xuehao.get()) root = tkinter.Tk() #创建Tkbutton = tkinter.Button(root,text='输入引用',background = "green",foreground="white",command=msgbox) #按

2020-12-10 11:10:55 576

原创 面向对象——计算身体质量的指数 进阶版

class BMI: def __init__():#定义不可的少 pass#防止进行不下去加个passclass BMI: def __init__(self,name,age,weight,height): self.name = name self.age = age self.weight = weight self.height = height self.bmi = self.we

2020-12-10 09:33:02 171

原创 面向对象——计算身体质量的指数

class BMI: def __init__(self,name,age,weight,high): self.name = name self.age = age self.weight = weight self.high = high def say_hello(self): self.jieguo=self.weight/self.high/self.high print("{

2020-12-06 20:15:37 243

原创 定义对象的定义输出的公、私有化

#定义Student类class Student: def __init__(self,name,xuehao,phone): self.name = name self.xuehao = xuehao self.phone = phone #__self.password = '123' #__代表私有化 def say_hello(self): print("你好,我是{n},密码是{p}".f

2020-12-03 12:13:22 93

原创 git的文件上传,修改和下载的基本操作

新建代码仓库(云端github,gitee,etc)*创建一个新的仓库*仓库的地址https://github.com/Yyyukiiii/demo.git本地代码上传至云端*本地的代码仓库(本地文件夹)*启动 git bash命令*linux操作命令pwd # 显示当前所在路径cd路径 # change directory,进入指定的路径下进入了本地的代码仓库(文件夹)ls-a # ls:list,-a:all 显示出当前路径下所有的文件及文件夹*初始化当前文件夹为一个git代码

2020-12-03 11:37:58 185

原创 数字游戏函数自定义版

def yuesefu(x,y): print(x) print(y) list1=[1 for i in range(1,x+1)] while len(list1) > y: list2=list1[0:3] list1.append(list2[0]) list1.append(list2[1]) list1.append(list2[2]) del list1[0:4]

2020-11-29 18:26:30 154

原创 自定义函数

def qiuhe(x,y): """ 用于求和的函数 Input: x:接收一个实数 y:接收一个实数 Output: 返回x+y的计算结果 """ print(x) print(y) z=x+y return zresult = qiuhe(1,2)#函数的调用12qiuhe(x=1,y=2)123...

2020-11-26 09:42:21 57

原创 demo 在每行后面加行号

line_max=0line_num=1code_in=open(r"C:/Users/yuki/demo.py","r").readlines()code_out=open("demo_new.py","w")for i in code_in: if (line_max<len(i)): line_max=len(i)for i in code_in: i=i.ljust(line_max+1).replace('\n','')+"#"+str(line_

2020-11-26 08:19:25 168

原创 walden中的词频计算

#打开并读取文件file=open(r'c:\Users\Administrator\Desktop\Walden.txt','r')lines=file.readlines()#要把每行拆成单词words=[]for line in lines: tmp_list =line.split(" ") for word in tmp_list: words.append(word) words['\n', 'Walden\n', '\n', 'Conte

2020-11-19 11:55:03 231

原创 随机抽取学号输出名字,分解➕完整

# 创建一个字典students,key是学号,value是姓名# 学生信息在students.csv文件中,从文件中读取并保存带字典#打开students.csv文件lines = open(r'/Users/apple/Desktop/students.csv','r').readlines()# 读取每行的序号和姓名,保存到字典students = {}for line in lines: tmp_list = line.split(',') xuehao = tmp_

2020-11-19 10:33:42 2510

原创 读取行加行号

lines_maxlenth = 0 #1line_numbers = 1 #2code_in = open("demo.py","r").readlines() #3code_out =ope

2020-11-19 09:45:55 82

原创 猜50内的数字

import randomi=1a=int(random.random()*50+1)while i<6: b=input() if(a==int(b)): print("正确") break elif(a<int(b)): print("大了") else: print("小了") i=i+1else: print("已超过5次")30小了40小了50大了45

2020-11-19 09:08:05 119

原创 python基本操作(字典)

字典dict= {'语文': 89, '数学': 92, '英语': 93} print(dict){'语文': 89, '数学': 92, '英语': 93}dict = {} print(dict){}dict2 = {(20, 30):'good', 30:'bad'} print(dict2){(20, 30): 'good', 30: 'bad'} scores = {'语文': 89}print(scores['语文'])89增加scores['数学

2020-11-19 08:33:04 426

原创 数字游戏 数字的加减

list1=[i for i in range(1,40)]print(list1)[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]while len(list1)>2: list2=list1[0:2] list1.append(l

2020-11-19 08:14:34 516

原创 Walden词频数据统计

import collectionst=open("/Users/apple/Desktop/Walden.txt","r").read()t=t.replace(',','').replace('.','').replace('"','').replace(':','')t=t.split()r=collections.Counter(t)print(r)Counter({'the': 6937, 'and': 4547, 'of': 3472, 'to': 3058, 'a': 2966,

2020-11-18 22:42:35 23962

原创 决策树的练习

导出网络数据#%matplotlib inlineimport numpy as npfrom sklearn.model_selection import train_test_splitfrom sklearn.datasets import load_irisfrom sklearn.tree import DecisionTreeClassifier加载iris数据集#iris = load_iris()X = iris.dataY = iris.target拆分训练集和测

2020-11-17 15:01:34 178

原创 随机抽取序号点名

1.创建字典,key是学号,value是姓名;2.从学号中随机抽取N个元素,打印输出;3.根据抽出的学号,查找对应的姓名;4.打印输出的姓名key ={1:'小黄',2:'小红',3:'小蓝'}from random import choicel = [1, 2, 3] a =choice(l) # 随机抽取一个print(key[a])小蓝import randomkey ={1:'小黄',2:'小红',3:'小蓝'}n=random.randint(1,3)key[n]

2020-11-12 11:31:06 1487

原创 去除相同元素

list = eval(input('请输入列表lst:'))请输入列表lst:[1,1,2,3,2,4,5,6,6]list2 = []for item in list: if (item not in list2): list2.append(item)print(list2)[1, 2, 3, 4, 5, 6]lst = eval(input())print(list(set(lst)))[1,2,3,1,2,3,4,4,5,5][1, 2, 3,

2020-11-12 09:55:08 114

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除