摘要: import requests from bs4 import BeautifulSoup ALL = [] def getHTMLtext(url): try: r = requests.get(url,timeout = 30) r.raise_for_status() r.encoding = 阅读全文
posted @ 2020-12-13 14:01 小松可可奈 阅读(192) 评论(0) 推荐(0)
摘要: 三、根据所给的html页面,保持为字符串,完成如下要求: (1)打印head标签内容和你学号的后两位 (2)获取body标签的内容 (3)获取id的first的标签对象 (4)获取并打印html页面中的中文字符 from bs4 import BeautifulSoup r = ''' <!DOCT 阅读全文
posted @ 2020-12-13 13:24 小松可可奈 阅读(437) 评论(0) 推荐(0)
摘要: 2)请用requests库的get()函数访问如下一个网站20次,打印返回状态,text()内容,计算text()属性和content属性所返回网页内容的长度。import requests for i in range(20): r=requests.get("https://cn.bing.co 阅读全文
posted @ 2020-12-13 13:07 小松可可奈 阅读(297) 评论(0) 推荐(0)
摘要: 1. 有基本函数的用法 Numpy: 来存储和处理大型矩阵,比Python自身的嵌套列表(nested list structure)结构要高效的多,本身是由C语言开发。这个是很基础的扩展,其余的扩展都是以此为基础。数据结构为ndarray,一般有三种方式来创建。 Pandas: 基于NumPy 的 阅读全文
posted @ 2020-11-22 13:31 小松可可奈 阅读(58) 评论(0) 推荐(0)
摘要: # -*- encoding:utf-8 -*- ''' 模拟乒乓球竞技 @author: bpf ''' # 比赛规则: # 1. 一场比赛: 单打:采用七局四胜制 # 双打淘汰赛、团体赛:采用五局三胜制 # 2. 一局比赛: 先得11分为胜,10平后,多得2分为胜 # 3. 一局比赛: 每队发球 阅读全文
posted @ 2020-11-21 16:54 小松可可奈 阅读(106) 评论(0) 推荐(0)
摘要: import jieba txt = open("聊斋志异白话简写版.txt", "r", encoding='utf-8').read() words = jieba.lcut(txt) # 使用精确模式对文本进行分词 counts = {} # 通过键值对的形式存储词语及其出现的次数 for w 阅读全文
posted @ 2020-11-15 09:36 小松可可奈 阅读(158) 评论(0) 推荐(0)
摘要: 第一种 class person: def kanchai(): print("小明,10岁,男,上山去砍柴") def kaiche(): print("小明,10岁,男,开车去东北") def dayouxi(): print("小明,10岁,男,最爱打游戏") no1 = person.kan 阅读全文
posted @ 2020-11-01 22:31 小松可可奈 阅读(66) 评论(0) 推荐(0)
摘要: import turtle as t import time def popspace(): #单管间隔 t.penup() t.fd(5) def popline(draw): #画数码管 popspace() t.pendown() if draw else t.penup() t.fd(40) 阅读全文
posted @ 2020-10-18 11:10 小松可可奈 阅读(198) 评论(0) 推荐(0)
摘要: import math import time scale=14 s,m,=1,2 print("执行开始".center(scale//2, "-")) start = time.perf_counter() for i in range(scale+1): s=math.sqrt((1-math 阅读全文
posted @ 2020-10-11 09:15 小松可可奈 阅读(60) 评论(0) 推荐(0)
摘要: from turtle import * r=Turtle() r.hideturtle() r.shape('turtle') r.up() r.back(300) r.left(50) r.showturtle() r.down() def rmove(): if usedtime<50: r. 阅读全文
posted @ 2020-09-21 20:11 小松可可奈 阅读(147) 评论(0) 推荐(0)