摘要: 知乎上的https://zhuanlan.zhihu.com/p/622026534 import turtle def plotLine(points, pencolor=None, width=None, speed=None): ''' 功能:画折线 参数: - points : 一系列点,用 阅读全文
posted @ 2026-10-27 15:41 叕叒双又 阅读(2) 评论(0) 推荐(0)
摘要: 目录pthon的基础是变量、输入输出、判断、循环和函数1 标识符标准:2 变量:用来完成程序中数值的读取或写入,函数中参数的传入与传出3 输入输出 pthon的基础是变量、输入输出、判断、循环和函数 1 标识符标准: 字符构成:字母大小写,数字和下划线组成 开头限制:不能以数字开始,下划线开始的多为 阅读全文
posted @ 2026-10-27 11:30 叕叒双又 阅读(2) 评论(0) 推荐(0)
摘要: 最开始的解决方法是使用判断选项的长度,借助tabular实现四个选项的一行、二行和四行排布方式。后来发现更简单的方法,记录如下: 1、应用包exam-zh-choices 2、使用choices环境 3、将选项依次写入choice的item后即可 具体代码: \usepackage{exam-zh- 阅读全文
posted @ 2026-10-25 16:57 叕叒双又 阅读(5) 评论(0) 推荐(0)
摘要: 1. 启用本地文档服务 python -m pydoc -p 1234,根据提示信息, 浏览器打开http://localhost:1234 ,点击需要查看的文档查看 2. 在线文档 多数库在pypi页面或github官方文档链接,搜索库名的documentation即可找到 3.查看--doc-- 阅读全文
posted @ 2026-10-23 18:17 叕叒双又 阅读(4) 评论(0) 推荐(0)
摘要: 目录一、准备需要的信息二、修改网络配置文件,配置文件在/etc/netplan/,文件是50-cloud-init.yaml 一、准备需要的信息 网卡名称例如ens33之类的,可以使用ip link show 或者ifconfig -a,结果类似etho, ens33, enp0s3等,记下网卡名; 阅读全文
posted @ 2026-10-21 11:18 叕叒双又 阅读(12) 评论(0) 推荐(0)
摘要: def dictCreaDemo(): dic1=dict() print(dic1) dic2=dict(王五=22) print(dic2) dic3={} print(dic3) dic4={'张三':18, '李四':20} print(dic4) del dic3 def getKeyva 阅读全文
posted @ 2026-10-14 18:22 叕叒双又 阅读(3) 评论(1) 推荐(0)
摘要: async def sayH(nu, s1): await asyncio.sleep(2) print(f'{nu}', end='') print(f'{s1}*{nu}') async def main(nu, s1): i=1 while i < nu: task=asyncio.creat 阅读全文
posted @ 2026-10-14 11:17 叕叒双又 阅读(4) 评论(0) 推荐(0)
摘要: ''' 迭代器的本质是使用iter()和next() 如果是python中的数据结构,无需实现即可 其他的需要自行实现 迭代器和生成器都是按需返回数据,这种惰性返回数据的方式能有效避免内存被快速占满 ''' def iterAppDemo(): fruits=['苹果','香蕉','橘子','菠萝' 阅读全文
posted @ 2026-10-13 21:21 叕叒双又 阅读(5) 评论(0) 推荐(0)
摘要: ''' 程序运行产生的数据只是在内存中,一旦退出程序,数据也随之消失; 需要将程序运行的数据保存时,就需要使用数据固化技术 ''' def readFileDemo(fileName, m): # 打开文件 file = open(fileName, m) # 读取文件 content = file 阅读全文
posted @ 2026-10-13 20:21 叕叒双又 阅读(2) 评论(0) 推荐(0)
摘要: def exceptDemo1(): print(f'根据输入的数字,若不是数字则抛出异常!') # 将可能出错的代码置于try块中 try: number=int(input('please input a number: ')) print(f'you input the numbe: {num 阅读全文
posted @ 2026-10-13 18:07 叕叒双又 阅读(6) 评论(0) 推荐(0)
摘要: class Agent: def __init__(self, name): self.name=name self.memory=[] def __str__(self): return f'Agent({self.name})' def __call__(self, a, b): f'{a}+{ 阅读全文
posted @ 2026-10-13 17:20 叕叒双又 阅读(5) 评论(0) 推荐(0)
摘要: ''' 不定长位置参数的形参前必须加上* 不定长关键字参数的形参前必须加上** 位置参数若在不定长参数前,正常传递参数即可 当位置参数位置在不定长参数后,传递时需要将其当成关键字参数传参即可 ''' def func1(*args): print(f'不定长位置参数:{args}') def fun 阅读全文
posted @ 2026-10-13 15:47 叕叒双又 阅读(1) 评论(0) 推荐(0)
摘要: 先实现父类Animal class Animal: # 魔法方法是完全自动执行,时机到了就会执行,无需能无法手动调用 def __init__(self, name, age): self.name=name self.age=age print(f'creat a {self.name} and 阅读全文
posted @ 2026-10-13 11:18 叕叒双又 阅读(3) 评论(0) 推荐(0)
摘要: x=20 def outer(): y = 99 def inner(): nonlocal y y = 9658 print('inner:',x,y) inner() #point1 print('outer',x,y) #inner() #point2 print('golbal:',x) o 阅读全文
posted @ 2026-10-13 07:17 叕叒双又 阅读(1) 评论(0) 推荐(0)
摘要: def tupleOperDemo(): import copy tup1=(1,2,3) tup2=copy.copy(tup1) tup3=copy.deepcopy(tup1) # 无论是copy还是deepcopy ID结果是一样的,主要是由于tup1中没有可变元素 print(id(tup 阅读全文
posted @ 2026-10-12 09:27 叕叒双又 阅读(3) 评论(0) 推荐(0)