摘要: 1、基本函数用法 Numpy: 基础的数学计算模块,来存储和处理大型矩阵,比Python自身的嵌套列表(nested list structure)结构要高效的多,本身是由C语言开发。这个是很基础的扩展,其余的扩展都是以此为基础。数据结构为ndarray,一般有三种方式来创建。 Scipy: 方便、 阅读全文
posted @ 2023-12-28 19:52 胡瑟苏娜 阅读(28) 评论(0) 推荐(0)
摘要: import jiebatxt = open("D:\\python\\西游记.txt", "r", encoding='ansi').read()words = jieba.lcut(txt) # 使用精确模式对文本进行分词counts = {} # 通过键值对的形式存储词语及其出现的次数for 阅读全文
posted @ 2023-12-20 11:17 胡瑟苏娜 阅读(20) 评论(0) 推荐(0)
摘要: import csvimport osimport requestsfrom bs4 import BeautifulSoupallUniv = []def getHTMLText(url): try: r = requests.get(url, timeout=30) r.raise_for_st 阅读全文
posted @ 2023-12-11 21:11 胡瑟苏娜 阅读(25) 评论(0) 推荐(0)
摘要: from bs4 import BeautifulSoup import re soup=BeautifulSoup('''<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> </h 阅读全文
posted @ 2023-12-11 21:07 胡瑟苏娜 阅读(17) 评论(0) 推荐(0)
摘要: import requests url="https://www.baidu.com/" def gethtml(url): try: r=requests.get(url) r.raise_for_status() r.encoding="utf-8" print("text内容:",r.text 阅读全文
posted @ 2023-12-11 21:03 胡瑟苏娜 阅读(18) 评论(0) 推荐(0)
摘要: from random import randomdef printIntro(): print("这个程序模拟两个选手A和B的某种竞技比赛") print("程序运行需要A和B的能力值(以0到1之间的小数表示)")def getInputs(): a = eval(input("请输入选手A的能力 阅读全文
posted @ 2023-11-20 21:09 胡瑟苏娜 阅读(16) 评论(0) 推荐(0)
摘要: import turtle, datetimedef drawGap(): #绘制数码管间隔 turtle.penup() turtle.fd(5)def drawLine(draw): #绘制单段数码管 drawGap() turtle.pendown() if draw else turtle. 阅读全文
posted @ 2023-11-20 19:59 胡瑟苏娜 阅读(29) 评论(0) 推荐(0)
摘要: #eraze_zero.pymoney= eval(input("请输入商品的总金额:"))money_str=str(money)print('商品总金额为:' + money_str)money2=int(money)money2_str=str(money2)print('实收金额为:' + 阅读全文
posted @ 2023-10-31 20:01 胡瑟苏娜 阅读(48) 评论(0) 推荐(0)
摘要: from random import randomfrom math import sqrtfrom time import perf_counterDARTS = 10000000hits = 0.0perf_counter()for i in range(1,DARTS+1): x,y = ra 阅读全文
posted @ 2023-10-30 19:42 胡瑟苏娜 阅读(49) 评论(0) 推荐(0)