11 2022 档案
摘要:(1)创建类(只包含方法) class 类名: def 方法1(self, 参数列表): pass def 方法2(self, 参数列表): pass self是必须参数,self代表对象本身 (2)创建对象 对象名 = 类名() 例:小猫叫爱吃鱼,小猫在喝水 class Cat: def eat(
阅读全文
摘要:# encoding:utf-8 from bs4 import BeautifulSoup import requests import csv import bs4 # 检查url地址 def check_link(url): try: r = requests.get(url) r.raise
阅读全文
摘要:# encoding:utf-8 import os import requests from bs4 import BeautifulSoup #爬虫头数据 cookies = { 'SINAGLOBAL': '6797875236621.702.1603159218040', 'SUB': '_
阅读全文
摘要:# encoding:utf-8 import requests import csv headers = { 'cookie':'device_id=02a63e162n=0035d9dae1eded6e3=1666944669347886', 'User-Agent': 'Mozilla/5.0
阅读全文
摘要:import time n=0 while n <10: print(n,"删除数据成功") n = n +1 if n == 10: n = 0 time.sleep(5) continue import time n=0 while True: print(n,"删除数据成功") n = n +
阅读全文
摘要:#1.两个字典的合并 x = {'a': 1, 'b': 2} y = {'c': 3, 'd': 4} x.update(y) print(x) #字典的合并 dct1={'name':'wjh','age':20} dct2={'city':'beijing','areas':'昌平区'} #方
阅读全文
摘要:字体颜色 print('\033[1;30m%s\033[0m' %("*" *116)) print('\033[1;31m%s\033[0m' %("*" *116)) print('\033[1;32m%s\033[0m' %("*" *116)) print('\033[1;34m%s\03
阅读全文