10 2022 档案

摘要:#!/usr/bin/env python# -*- encoding:utf-8 -*-'''import csvheaders=['学号','姓名','分数']rows=[('202001','张三','98'), ('202002','李四','95'), ('202003','王五','96 阅读全文
posted @ 2022-10-18 03:07 布衣梦蝶1978 阅读(32) 评论(0) 推荐(0) 编辑
摘要:1. 基本功能 建议使用pathlib模块来处理文件和文件夹,可以跨平台。pathlib提供path对象来操作,包括目录和文件。 In [1]: from pathlib import Path In [2]: p=Path() In [3]: pOut[3]: WindowsPath('.') I 阅读全文
posted @ 2022-10-17 01:52 布衣梦蝶1978 阅读(328) 评论(0) 推荐(0) 编辑
摘要:import os #获取系统名称 print(f'系统的名称{os.name}') #win系统的名称nt #获取当前文件的绝对路径 print(f'获取当前文件的绝对路径:{os.getcwd()}') ''' 绝对路径:从具体的盘符开始到指定文件结束 相对路径: 参照物的 当前的文件 路径盘符 阅读全文
posted @ 2022-10-16 02:07 布衣梦蝶1978 阅读(42) 评论(0) 推荐(0) 编辑
摘要:编写程序统计一个英文文本文件中单词的出现次数,并将出现次数最多(次数排名前10)的单词和它们的出现次数按降序显示。 1. 使用一个字典来存储包含了单词和它的次数的条目; 2. 统计单词是不考虑大小写的,例如:认为Good与good是一个单词; 第一步:读取文件通过txt.lower()函数将字母变成 阅读全文
posted @ 2022-10-16 01:35 布衣梦蝶1978 阅读(162) 评论(0) 推荐(0) 编辑
摘要:#获取系统名称In [235]: os.nameOut[235]: 'nt' #win系统的名称nt #获取当前文件的绝对路径In [236]: os.getcwd()Out[236]: 'D:\\djangoPro\\sample\\1' '''绝对路径:从具体的盘符开始到指定文件结束相对路径:参 阅读全文
posted @ 2022-10-15 18:29 布衣梦蝶1978 阅读(79) 评论(0) 推荐(0) 编辑
摘要:'''要求: 程序员可以方便的注册函数到某个命令,用户输入命令时,路由到注册的函数,如果没有此命令,执行默认函数,用户输入input分析:输入命令映射到一个函数,并执行这个函数,应该cmd_tb1[vmd]=fn的形式,字典正好合适。如果输入了某个cmd命令后,没有找到函数,就要调用缺省的函数执行, 阅读全文
posted @ 2022-10-15 03:58 布衣梦蝶1978 阅读(65) 评论(0) 推荐(0) 编辑
摘要:'''source={'a':{'b':1,'c':2},'d':{'e':3,'f':{'g':4}}}target={}def fun(sdict,dictkey=''): for k,v in sdict.items(): if isinstance(v,dict): fun(v,dictke 阅读全文
posted @ 2022-10-12 08:19 布衣梦蝶1978 阅读(76) 评论(0) 推荐(0) 编辑
摘要:'''def counter(base): def inc(step=1): nonlocal base base+=step return base return incfoo=counter(5)foo2=counter(5)print(foo==foo2)'''#sorted# def com 阅读全文
posted @ 2022-10-12 08:17 布衣梦蝶1978 阅读(37) 评论(0) 推荐(0) 编辑
摘要:<script> /** 链接:https://www.jianshu.com/p/7e160067a06c 二、数组方法概括 方法名 对应版本 功能 原数组是否改变 concat() ES5- 合并数组,并返回合并之后的数据 n join() ES5- 使用分隔符,将数组转为字符串并返回 n po 阅读全文
posted @ 2022-10-11 03:24 布衣梦蝶1978 阅读(74) 评论(0) 推荐(0) 编辑
摘要:#1 #asyncio 没有提供http协议的接口 aiohttp ''' import asyncio import socket from urllib.parse import urlparse async def get_url(url): # 通过socket请求html url = ur 阅读全文
posted @ 2022-10-10 17:53 布衣梦蝶1978 阅读(22) 评论(0) 推荐(0) 编辑
摘要:# 1''' import asyncio async def main(): print('hello') await asyncio.sleep(1) print('world') if __name__=="__main__": asyncio.run(main()) # hello # wo 阅读全文
posted @ 2022-10-10 17:44 布衣梦蝶1978 阅读(121) 评论(0) 推荐(0) 编辑
摘要:编写一个函数,能够接受至少2个参数,返回最小值 和最大值 import random def double_values(*nums): print(nums) return max(nums),min(nums) print(*double_values(*[random.randint(10,2 阅读全文
posted @ 2022-10-10 09:51 布衣梦蝶1978 阅读(86) 评论(0) 推荐(0) 编辑
摘要:# def outer1():# o=65# def inner():# print("inner {}".format(o))# print(chr(o))# print("outer {}".format(o))# inner()# outer1() def outer1(): o=65 def 阅读全文
posted @ 2022-10-10 09:42 布衣梦蝶1978 阅读(39) 评论(0) 推荐(0) 编辑
摘要:'''#协程原理import timedef sleep(n): print('start sleep') yield time.time()+n print('end sleep')def func(n): print(123) g=sleep(n) yield from g print(456) 阅读全文
posted @ 2022-10-09 18:51 布衣梦蝶1978 阅读(60) 评论(0) 推荐(0) 编辑
摘要:from pyquery import PyQuery as pqfrom lxml import etreeimport urllib# d=pq("<html></html>")# d=pq(etree.fromstring("<html></html>"))# d=pq(url=your_ur 阅读全文
posted @ 2022-10-09 14:52 布衣梦蝶1978 阅读(30) 评论(0) 推荐(0) 编辑
摘要:# numbers=[]# for number in range(10):# numbers.append(number)# print(numbers)# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]# VAT_PERCENT=0.1## def add_vat(price):# 阅读全文
posted @ 2022-10-08 08:53 布衣梦蝶1978 阅读(91) 评论(0) 推荐(0) 编辑
摘要:1.集合的常用方法集合:无序的数据类型添加顺序和在集合中的存储顺序是不一样的1.增加 增加一个元素.add() s = {6,7,8,9} s.add(1) print(s) 打印结果 {1, 6, 7, 8, 9} 增加一个集合.uppdate() s = {6,7,8,9} s.update({ 阅读全文
posted @ 2022-10-06 09:32 布衣梦蝶1978 阅读(322) 评论(0) 推荐(0) 编辑
摘要:ES6中的set类似一个数组,但是其中的值都是唯一的,Set本身是一个构造函数,用来生成 Set 数据结构。 set函数可以接受一个数组作为参数,用来初始化: const set = new Set([1, 2, 3, 4, 4, 4]); [...set] //输出结果:[1, 2, 3, 4] 阅读全文
posted @ 2022-10-04 10:07 布衣梦蝶1978 阅读(2647) 评论(0) 推荐(0) 编辑
摘要:一、partition()函数的语法格式 string_name.partition(separator) (1)string_name 为要被分隔的字符串或字符串变量。 (2)该函数有一个字符串类型的参数:separator,该参数用于指定分隔原字符串的字符串; (3)该函数的返回类型为元组类型, 阅读全文
posted @ 2022-10-04 08:51 布衣梦蝶1978 阅读(709) 评论(0) 推荐(0) 编辑
摘要:第一次ES6 // let school = 'magedu' // console.log(school.charAt(2))// g // console.log(school[2])// g // console.log(school.toUpperCase())// MAGEDU // co 阅读全文
posted @ 2022-10-03 17:59 布衣梦蝶1978 阅读(27) 评论(0) 推荐(0) 编辑
摘要:第一次使用:字符串操作 In [1]: lst=[11,12,13,7,1,3,2,2,5,6,10,7] In [2]: lst Out[2]: [11, 12, 13, 7, 1, 3, 2, 2, 5, 6, 10, 7] In [3]: lst1=[11,12,13,7,1,3,2,2,5, 阅读全文
posted @ 2022-10-03 17:56 布衣梦蝶1978 阅读(17) 评论(0) 推荐(0) 编辑