01 2020 档案
摘要:with语句适用于对资源进行访问的场合,确保不管使用过程中是否发生异常都会执行必要的“清理”操作,释放资源,比如文件使用后自动关闭、线程中锁的自动获取和释放等。 例1:url = 'http://www.weather.com.cn/' + province + '/index.shtml'with
阅读全文
摘要:Python的程序有两中退出方式:os._exit(), sys.exit() os._exit()会直接将python程序终止,之后的所有代码都不会继续执行。 sys.exit()会引发一个异常:SystemExit,如果这个异常没有被捕获,那么python解释器将会退出。如果有捕获此异常的代码,
阅读全文
摘要:import random import requests def get_htmla(url): aui=0 while aui==0: try: header={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.
阅读全文
摘要:1。整理好答案文件为文本文件;不能有空行;每个题干前有数字做为题号;每个题答案第一个字符为字母,答案占一行import time import time import sys import os import re import tkinter import tkinter.messagebox #
阅读全文
摘要:Python split()方法Python split() 通过指定分隔符对字符串进行切片,如果参数 num 有指定值,则分隔 num+1 个子字符串str.split(str="", num=string.count(str)).参数str -- 分隔符,默认为所有的空字符,包括空格、换行(\n
阅读全文
摘要:import requestsimport re txt='<a href="https://www.vgirls.com/13404.html" class="list-title text-md h-2x" target="_blank">想把夏日的阳光寄给冬日的你</a>'urla=re.fi
阅读全文
摘要:from PIL import Imagefrom PIL import ImageEnhanceim=Image.open("d://aa.jpg","r")print(im.size,im.format,im.mode) #显示图的大小,格式,模式brightness = ImageEnhanc
阅读全文
摘要:import osimport timeimport tarfileimport zipfile'''mysqldumpUsage: mysqldump [OPTIONS] database [tables]OR mysqldump [OPTIONS] --databases [OPTIONS] D
阅读全文
摘要:SQLITE数据库不支持远程访问 import sqlite3 conn=sqlite3.connect("dailiaq.db") cur=conn.cursor() def create(): sql = '''CREATE TABLE `mydlax1aa` (ID INTEGER PRIMA
阅读全文