![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
lichar03
这个作者很懒,什么都没留下…
展开
-
/python课程设计/读取文件遇到的问题
open(,,),如果没有解码方式会输出UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 14:illegal multibyte sequence;p.s.此处解码方式为encode=“UTF-8”另外注意区分read(),和readlines()的区别,此处仍然有一些困惑,在后续的学习中继续解决这个问题原创 2017-07-27 10:48:46 · 750 阅读 · 0 评论 -
python 网页爬虫(URL)
这是一篇课程总结。课程来源: 慕课网需要爬网页做成pdf方便打印。Module 分成五个部分:网页下载器,网页解析器,网页信息的输出,,URL管理,主调度程序。Python 3.5+,需要用到urllib2 re urlparse bs4 四个库 。主调度程序:from baike_spider import url_manager, html_downloader, ht原创 2017-10-24 21:58:01 · 615 阅读 · 1 评论 -
Tensorflow CNN 的简单实现
教学视频:莫烦python有空自己整理复写一遍~mark# encoding:utf8import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets('MNIST_data', one_hot=True)d原创 2017-10-23 19:38:38 · 235 阅读 · 0 评论 -
tensorflow 实战笔记
#encoding:utf8#一个去躁自编码器#来源:tensorflow实战4.2 P65import numpy as npimport sklearn.preprocessing as prepimport tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data#实现Xaive原创 2017-10-29 16:32:36 · 344 阅读 · 0 评论 -
每天一python 题 0006
#第 0006 题: 你有一个目录,放了你一个月的日记,都是 txt,为了避免分词的问题,假设内容都是英文,请统计出你认为每篇日记最重要的词。import re,osre_word=re.compile(r'[a-z]+')#获得当前目录下文件后缀为txt的文档,并返回其名称def get_files(): cwd=os.getcwd() txt_name=[]原创 2017-09-30 15:52:26 · 746 阅读 · 0 评论 -
python 字典的问题
#Part I要遍历过程中,如果没有keys=list(counts.keys()) #对keys转换成list,不再是dict_key.对字典的处理过程中删除增加会报错#del counts[key]也可以换成counts.pop(key)#Part II上述写法可以更为精简,参考: Python if 和 for 的多种写法#源代码是Mooc的pytho原创 2017-09-30 14:50:48 · 1705 阅读 · 0 评论 -
每天一python 题 0005
#第 0005 题: 你有一个目录,装了很多照片,把它们的尺寸变成都不大于 iPhone5 分辨率的大小。from PIL import Imageimport osimport math#将符合分辨率的图片和修改不符合后的图片放在一个新的文件中#改变不符合要求的图片def change_size(pics): for pic in pics: new_pic原创 2017-09-21 18:09:53 · 224 阅读 · 0 评论 -
每天一python 题 0004
# 第 0004 题: 任一个英文的纯文本文件,统计其中的单词出现的个数。import rere_word=re.compile(r'[a-zA-Z]+')def count_words(object): count = 0 for line in object: nums=re_word.findall(line) count+=le原创 2017-09-20 16:10:14 · 209 阅读 · 0 评论 -
python 正则表达式的练习
关于用法:https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/00143193331387014ccd1040c814dee8b2164bb4f064cff000#0廖大已经解释的很详细了。一个小小的demo,检验email格式的问题:import redef原创 2017-09-20 12:59:40 · 329 阅读 · 0 评论 -
每天一python 题 0003
#第 0003 题: 将 0001 题生成的 200 个激活码(或者优惠券)保存到 Redis 非关系型数据库中。import redisr=redis.Redis(host='127.0.0.1',port=6379)outfile = open("ex0003.txt", "r")coupons=[]for line in outfile: print(line) c原创 2017-09-17 00:15:13 · 197 阅读 · 0 评论 -
每天一python 题 0001
#-*- coding:utf-8 -*-#第 0001 题: 做为 Apple Store App 独立开发者,# 你要搞限时促销,为你的应用生成激活码(或者优惠券)# ,使用 Python 如何生成 200 个激活码(或者优惠券)?import random,stringsam=string.ascii_letters+string.digitsdef get_coupon(n原创 2017-09-08 12:24:14 · 275 阅读 · 0 评论 -
pycharm快捷键
在PyCharm /opt/pycharm-3.4.1/help目录下可以找到ReferenceCard.pdf快捷键英文版说明PyCharm Default KeymapPyCharm3.0默认快捷键(翻译的)1、编辑(Editing)Ctrl + Space 基本的代码完成(类、方法、属性)Ctrl + Alt + Space 快速导入任意类Ctrl + Shift转载 2017-09-08 12:07:22 · 165 阅读 · 0 评论 -
每天一python 题 0002
第 0002 题: 将 0001 题生成的 200 个激活码(或者优惠券)保存到 MySQL 关系型数据库中。涉及的内容:python操纵MySQL数据库,推荐慕课网的相关课程;作业代码如下:代码中把01题又重新做了一边,但是这就不能保证是我之前的优惠券了;正确的做法该是将上次的优惠券存入文档中然后再读取;https://github.com/Show-Me-the-C原创 2017-09-15 13:15:59 · 317 阅读 · 0 评论 -
每天一python 题 0000
题目网站 https://github.com/Yixiaohan/show-me-the-code0000题答案from PIL import Image,ImageFont,ImageDrawim=Image.open('bg.png')(width,height)=im.sizedraw=ImageDraw.Draw(im)newfont=ImageFont.truety原创 2017-09-07 12:17:30 · 292 阅读 · 0 评论 -
Python2.7+Opencv 人脸检测
一个官网的demo:来源:http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html#face-detectionpython3下搭建环境实在很烦……两小时都没搞定,于是我放弃了……我就用python2吧 不知道2和3版本的真正区别(除了pr翻译 2017-09-13 16:05:59 · 416 阅读 · 1 评论 -
Python 问题集
1.列表list叠加 一个失败的例子:这时候需要用到append(),如果只对第一维做分离可以直接用a[i];2.class 中self的问题self可使外部函数中调用变量;方法中的定义的带self变量需要在类中初始化函数中执行才可以用;原创 2018-01-22 13:15:22 · 192 阅读 · 0 评论