摘要: import pymysql#connection = pymysql.connect(host='127.0.0.1',port=3306,user='root',password='password',db='transfer_money',charset='utf-8')config = { 'host':'127.0.0.1', 'port':3306, 'user':... 阅读全文
posted @ 2017-05-24 16:17 云ime 阅读(146) 评论(0) 推荐(0) 编辑
摘要: import jsonimport reimport requestsfrom bs4 import BeautifulSoupfrom requests import RequestExceptionfrom multiprocessing import Pooldef get_one_page( 阅读全文
posted @ 2017-05-13 18:27 云ime 阅读(600) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python# -*-coding:utf-8-*-# 第 0013 题: 第 0013 题: 用 Python 写一个爬图片的程序,爬 这个链接里的日本妹子图片 :-)import osimport requestsfrom bs4 import BeautifulS 阅读全文
posted @ 2017-05-13 11:54 云ime 阅读(337) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python# -*-coding:utf-8-*-# 第 0012 题: 敏感词文本文件 filtered_words.txt,里面的内容 和 0011题一样,当用户输入敏感词语,则用 星号 * 替换,# 例如当用户输入「北京是个好城市」,则变成「**是个好城市」。i 阅读全文
posted @ 2017-05-13 10:06 云ime 阅读(536) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python# -*-coding:utf-8-*-# 第 0011 题: 敏感词文本文件 filtered_words.txt,里面的内容为以下内容,# 当用户输入敏感词语时,则打印出 Freedom,否则打印出 Human Rights。import redef f 阅读全文
posted @ 2017-05-13 09:36 云ime 阅读(582) 评论(0) 推荐(0) 编辑
摘要: # split(pattern,string,maxsplit=0,flag=0 # split根据匹配到的字符串来分割字符,返回分割字符串组成的列表 import re str4 = 'imooc:C C++ Java Python' info_split1 = re.split(r':| ',s 阅读全文
posted @ 2017-05-12 16:09 云ime 阅读(302) 评论(0) 推荐(0) 编辑
摘要: 现在开始每天做一个Python小练习,第一个练习 一、图片的打开与显示 虽然使用的是Pillow,但它是由PIL fork而来,因此还是要从PIL中进行import. 使用open()函数来打开图片,使用show()函数来显示图片。 这种图片显示方式是调用操作系统自带的图片浏览器来打开图片,有些时候 阅读全文
posted @ 2017-05-11 22:08 云ime 阅读(317) 评论(0) 推荐(0) 编辑
摘要: 为了方便爬虫,最近学习了正则表达式,将学习的过程记录如下: 一、正则表达式的概念: 1.使用单个字符串来描述匹配一系列符合某个句子语法规则的字符串 2.是对字符串操作的一种逻辑公式 3.应用来处理文本和数据 4.表达过程:依次拿出表达式和文本中的字符比较,如果每一个字符都能匹配,则匹配成功,否则匹配 阅读全文
posted @ 2017-05-02 11:26 云ime 阅读(307) 评论(0) 推荐(0) 编辑
摘要: 今天在搜用Python求阶乘的时候, 搜出来的最简单的是用reduce这个built-in function, 但是我在用reduce的时候, 却报NameError: name 'reduce' is not defined. 于是又搜了一下,发现在python 3.0.0.0以后, reduce 阅读全文
posted @ 2017-04-30 10:25 云ime 阅读(244) 评论(0) 推荐(0) 编辑
摘要: sqrt() 方法返回数字x的平方根 语法: 注意:sqrt()是不能直接访问的,需要导入 math 模块,通过静态对象调用该方法。 import math # This will import math module print ("math.sqrt(100) : ", math.sqrt(10 阅读全文
posted @ 2017-04-30 09:58 云ime 阅读(833) 评论(0) 推荐(0) 编辑