![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python学习笔记
htt789
这个作者很懒,什么都没留下…
展开
-
使用python绘制散点图
// Import necessary packages from matplotlib import pyplot as plt import numpy as np //定义一个函数实现利用文档中某几列数据生成散点图 def plotData(x1,y1,x2,y2): plt.figure(figsize=(8,8))#设置图片大小 plt.scatter(x1,...原创 2018-03-23 09:21:08 · 1148 阅读 · 1 评论 -
numpy.zeros 使用
函数zeros()在模块numpy中 import numpy as np 该函数功能是创建给定类型的矩阵,并初始化为0 用法:zeros(shape, dtype=float, order='C') shape:指定新矩阵大小 np.zeros(2) array([ 0., 0.,]) np.zeros((2, 1))或np.zeros([2, 1]) array([[ 0.],...原创 2018-03-20 10:59:06 · 1056 阅读 · 0 评论 -
print使用
python2的print和python3的print()区别是在python3.x中需要添加() 1.print向终端输出指定内容 python2.x语句为 print 'hello!' python3.x语句为 print ('hello!') 2.多个字符串用逗号“,”隔开 python2.x语句为 print 'i','love','you' python3.x语句为 prin...原创 2018-03-20 11:20:17 · 255 阅读 · 0 评论 -
python 遍历文件夹、正则表达式字符串匹配、拷贝文件
1.遍历目录: os.walk(dirpath) 返回三元组(root,dirs,files) root 所指的是当前正在遍历的这个文件夹的本身的地址 dirs 是一个 list ,内容是该文件夹中所有的目录的名字(不包括子目录) files 同样是 list , 内容是该文件夹中所有的文件(不包括子目录) 如下文件夹结构 a -> b -> 1.txt, 2.txt ...原创 2018-12-11 15:04:33 · 6668 阅读 · 0 评论 -
爬虫
#-- coding:utf-8 -- import re import requests import string import os import random def dowmload_image(html, path,s_name): image_url = re.findall(’“objURL”:"(.*?)",’, html, re.S) print(‘len_image_url...原创 2018-12-10 16:36:48 · 158 阅读 · 0 评论 -
python 压缩文件为zip格式
1.创建zip压缩对像 f=zipfile.ZipFile(file, mode="", compression=ZIP_STORED, allowZip64=False) “file”:生成的文件路径+名称 mode='w’压缩文件 2.将文件写入zip压缩文件 f.write(filepath)将文件直接写入压缩文件 f.write(filepath,dstdir+filename)将文件打包...原创 2019-03-25 17:43:54 · 3650 阅读 · 0 评论