2018年3月13日
摘要: from urllib.request import urlopenfrom bs4 import BeautifulSouphtml = urlopen("http://www.pythonscraping.com/pages/page3.html")bsObj = BeautifulSoup(h 阅读全文
posted @ 2018-03-13 15:56 学习代码小仓库 阅读(87) 评论(0) 推荐(0) 编辑
摘要: #coding:utf-8from urllib.request import urlopenfrom bs4 import BeautifulSoupfrom urllib.error import HTTPError,URLErrordef getinfo(url): try: html = u 阅读全文
posted @ 2018-03-13 15:54 学习代码小仓库 阅读(160) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*-import os #载入操作系统模块,用于文件及文件夹操作import re #载入正则表达式模块import shutil #载入文件操作模块Fnames = re.compile("spam" + "\d{3}" + "\.txt") #定义出sp 阅读全文
posted @ 2018-03-13 15:50 学习代码小仓库 阅读(472) 评论(0) 推荐(0) 编辑
摘要: import os #载入操作系统模块,用于文件及文件夹操作import send2trash #载入安全删除模块Fnames = (".txt") #定义出txt文件for foldername,subfolders,filenames in os.walk(str(os.getcwd())): 阅读全文
posted @ 2018-03-13 15:49 学习代码小仓库 阅读(140) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*-def checkpsd(psd): import re while True: key = re.compile(r"[^0-9A-Za-z]+") #定义非法字符 key1 = re.compile(r"\d+") #定义至少一个数字 key2 = 阅读全文
posted @ 2018-03-13 15:48 学习代码小仓库 阅读(264) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*-import random #载入随机函数模块import logging #载入日志模块logging.basicConfig(filename="log.txt",level=logging.DEBUG,format = " %(asctime)s 阅读全文
posted @ 2018-03-13 15:47 学习代码小仓库 阅读(162) 评论(0) 推荐(0) 编辑
摘要: #coding:utf-8import sys #用于设置默认编码from selenium import webdriver #用于进行网页元素定位import re #正则表达式import os #用于操作文件夹import urllib #用于下载图片import time #用于暂停imp 阅读全文
posted @ 2018-03-13 15:45 学习代码小仓库 阅读(1305) 评论(0) 推荐(0) 编辑
摘要: import os #载入操作系统模块,用于文件及文件夹操作import shutil #载入文件操作模块Fnames = (".txt") #定义出txt文件for foldername,subfolders,filenames in os.walk(str(os.getcwd())): #os. 阅读全文
posted @ 2018-03-13 15:41 学习代码小仓库 阅读(283) 评论(0) 推荐(0) 编辑
摘要: import os #载入操作系统模块,用于文件及文件夹操作import sys #载入系统模块import io #载入读写模块sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding="utf-8") #标准输出(sys.stdout)设置 阅读全文
posted @ 2018-03-13 15:39 学习代码小仓库 阅读(119) 评论(0) 推荐(0) 编辑