笔记本推荐
文章平均质量分 53
gs_every
这个作者很懒,什么都没留下…
展开
-
笨办法学Python
学习python前的准备工作: 首先要安装python,关于如何安装,请参考http://www.imooc.com/video/3326,视频讲解。 其次是安装编辑器,windows系统选择的是notepad++文本编辑器,用浏览器打开https://notepad-plus-plus.org/ ,点击 download,选择版本。 我们以后都将在命令行终端PowerShell中运行Py原创 2017-07-17 15:56:23 · 877 阅读 · 0 评论 -
python文件操作
打开模式‘r’以只读方式打开文件(默认) >>> open('f:\\learn\\copied.txt')<open file 'f:\\learn\\copied.txt', mode 'r' at 0x000000000370D660>‘w’ 以写入的方式打开文件,会覆盖已存在的文件 ‘x’ 如果文件已存在,使用此模式打开将引发异常 ‘a’ 以写入模式打开,如果文件存在,则在文件末尾追加转载 2017-09-25 16:01:07 · 262 阅读 · 0 评论 -
python2.7 编码问题
Python报错:unicodedecodeerror ascii codec can t decode byte 0xe5 in position 0 ordinal not in range 128那些年我们用Python读写中文遇到的乱码问题及IDLE中文编码问题 字符串在Python内部的表示是unicode编码,因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的转载 2017-08-30 19:40:26 · 456 阅读 · 0 评论 -
RE库
#正则表达式#操作符. #表示任何单个字符[] # 字符集,对单个字符给出取值范围, [abc] 表示a, b,c [a-z] 表示a到z单个字符[^ ] #非字符集,对单个字符给出排除范围 [^abc]表示非a或b或c的单个字符* #前一个字符0次或无限次扩展 abc* 表示ab, abc, abc, 等*? #应用于前接字符,以非贪婪模式,表示前接字符的0个或无限个匹配*? #前一个原创 2017-08-17 12:08:41 · 350 阅读 · 0 评论 -
requests库
pip install requests 安装requests库 import requestsr = rests.get(url)返回两个对象,response 对象和request对象 response包含爬虫返回的内容r.status_code# HTTP请求返回状态,200表示连接成功,404表示失败r.text #HTTP相应内容的字符串形式,即url对应的页面内容r.encoding原创 2017-07-17 18:25:56 · 600 阅读 · 0 评论 -
Scrapy框架小例入门
scrapy1.4.0.创建一个项目scrapy startproject tutorial #项目名#其中包含tutorial/ scrapy.cfg # 部署配置文件 tutorial/ # project's Python module, you'll import your code from here __ini原创 2017-08-16 21:34:24 · 396 阅读 · 0 评论 -
笨办法学python ex29-35
ex29# -*- coding: utf-8 -*-people = 20cats = 30dogs = 15if people < cats: print "Too many cats! The world is doomed!" if people > cats: print "Not many cats! The world is saved!"if people原创 2017-07-17 18:02:44 · 621 阅读 · 0 评论 -
Python关键字及其用法
Python有哪些关键字-Python常用的关键字 and, del, from, not, while, as, elif, global, or, with, assert, else, if, pass, yield, break, except, import, print, class, exec, in, raise, contiue, finally, is, return, def原创 2017-07-31 09:42:38 · 22728 阅读 · 1 评论 -
python 的逻辑关系
NOT | TRUE? not False -> True not True -> FalseOR | True? True or True -> True True or False-> True False or True -> True False or False -> FalseAND | True? False and False -> False原创 2017-07-17 17:55:56 · 3104 阅读 · 0 评论 -
笨办法学python ex21-26
ex21 函数中有return可以返回值,没有return函数返回的是None# -*- coding: utf-8 -*-def add(a, b): print "ADDING %d + %d" %(a, b) return a + bdef subtract(a, b): print "SUBTRACTING %d - %d" % (a, b) return原创 2017-07-17 16:29:43 · 632 阅读 · 0 评论 -
笨办法学python ex11-20
ex11# -*- coding: utf-8 -*-print "How old are you?" # add ',(comma)' 防止输出新行,结束此行age = raw_input()print "How tall are you?",height = raw_input() # 接受,而input(),把输入 sth 当python 代码处理print "How much do原创 2017-07-17 16:16:56 · 543 阅读 · 0 评论 -
easygui库
import easygui as gdef msgbox(msg='消息参数',title='标题参数,默认空字符串',ok_button='ok,按钮')我们在调用时可以通过重写关键字参数,更改g.msgbox(msg='消息参数',title='标题参数,默认空字符串',ok_button='啦啦啦')ccbox(msg=’消息’,title=’ ‘,choices=(‘Conti原创 2017-09-25 17:16:47 · 733 阅读 · 0 评论