python基础
just to test
更多关于我 http://www.linhuajian.icu
展开
-
IDE工具使用指南
1、Sublime Text 配置python编译环境{ "cmd": ["D:/software/python3/python.exe","-u","$file"], "file_regex":"^[ ]*File \"(...*?)\", line ([0-9]*)", "selector":"source.python", “encoding”:"cp936",#解决中文乱码}...原创 2020-09-10 22:05:22 · 193 阅读 · 0 评论 -
python入门指南(七)excel操作
#!/usr/bin/env python# -*- coding:utf-8 -*-import osfrom xlrd import open_workbookfrom xlutils.copy import copyimport timeimport reclass Test4: def getdata(self): ###########...原创 2018-10-15 11:50:05 · 508 阅读 · 0 评论 -
python入门指南(二)python依赖库安装
pip install -r requirements.txtairtest==1.0.27asn1crypto==0.24.0AWSIoTPythonSDK==1.4.7bcrypt==3.1.7bleach==3.1.0boto3==1.10.7botocore==1.13.7cached-property==1.5.1certifi==2019.6.16cffi==...原创 2020-04-27 16:25:50 · 614 阅读 · 0 评论 -
python入门指南(四)播放音频
一、python播放音频文件下面是一些可以播放和录制音频的Python第三方库:playsound,支持MP3和WAV,目前只支持简单的回放。 simpleaudio,支持WAV,提供检查文件是否仍在播放的功能。 python-sounddevice和pyaudio为PortAudio库提供绑定,以便跨平台回放WAV文件。 pydub,需要pyaudio来播放音频,但是安装了ffmp...原创 2020-04-14 23:26:19 · 918 阅读 · 0 评论 -
python入门指南(五)编码问题
1、写中文文件乱码with io.open(code_log_path,"a+",encoding='utf-8') as f: f.write(unicode("\xEF\xBB\xBF", "utf-8")) f.write(u'{}\n'.format(ss))2、Python将字符串格式的unicode编码转换成unicode编码,...原创 2020-01-11 15:04:23 · 193 阅读 · 0 评论 -
python入门指南(三)计算文件的md5值
# coding=utf-8import hashlibimport osimport datetimedef GetFileMd5(filename): if not os.path.isfile(filename): print "文件路径错误" return myhash = hashlib.md5() f = open(f...原创 2018-11-21 11:44:50 · 529 阅读 · 0 评论 -
python入门指南(六)Python计算文件夹大小、获取字符串MD5 、获取字符串sha1
"""查看文件夹下的所有文件及文件夹"""def Look_File(path): for root , dirs, files in os.walk(path, True): for item in files: #主目录下的文件夹 os.path.join(root, item)"""计算文件夹 大小"""def FileSize(p...原创 2018-11-22 14:40:44 · 678 阅读 · 0 评论 -
python入门指南(一)python 项目打包
在Administrator|当前,目录下1.spec文件生成 pyi-makespec -w xxx.py2、配置图片,配置文件依赖#打开cmd运行窗口console=True#配置文件等,需要用文件绝对路径datas=[('C:\\Users\\Administrator\\Desktop\\\xa3\xc1\xa3\xd4\\linhuajian\\au...原创 2019-01-29 17:58:02 · 718 阅读 · 0 评论 -
python入门指南(十二)python将图片转化为数组
交流qq群:6515873171、转化为数组-*- coding: utf-8 -*-from PIL import Imagefrom pylab import *#读取图片并转为数组im = array(Image.open("C:\\Users\\Administrator\\Desktop\\22.png"))#输出数组的各维度长度以及类型print im.shap...原创 2018-12-09 15:17:56 · 15791 阅读 · 0 评论 -
python入门指南(八)python 方法执行两次,默认参数被修改
1、解决方案一:通过引入参数解决def getPictureType(self,purls={}):#通过再添加一个变量解决 result = {} if purls=={}: picurls = {} else : picurls = purls if picurls == {}: 。。。2、在调用...原创 2018-12-26 10:10:45 · 1047 阅读 · 0 评论 -
python入门指南(九) 正则使用
1、正则多个匹配条件例:去除列表字符中括号,两个匹配条件 用 | 分开re.sub(r'\[|\]',"",str)匹配一组规则#如把 23h34d 替换成''re.sub(r'\d+h+\d+d',''str)2、常用条件 :\w 匹配字母数字及下划线 \W 匹配非字母数字及下划线 \s 匹配任意空白字符,等价于 [\t\n\r\f]....原创 2019-01-15 11:31:46 · 144 阅读 · 0 评论 -
python入门指南(十一) Python字符串处理
1、literal_eval (列表格式字符串转列表) 用法:literal_eval(str)2、字符编码3、python split 后多了一个空格 解决方案:filter(None, s.split(' ')) ...原创 2019-01-15 16:42:28 · 144 阅读 · 0 评论 -
python入门指南(十)Python字典有序输出(解决urlcode参数必须是有序的问题)
import collectionsdata=collections.OrderedDict()data["sensorValue"]=33458data = urllib.urlencode(data)原创 2019-02-15 17:13:46 · 404 阅读 · 0 评论