上一页 1 2 3 4 5 6 7 ··· 23 下一页
摘要: 使用OS模块,使用os.listdir获取当前路径下的文件名列表(不获取子目录),os.rename重命名。 import os, sys # 导入模块。 from itertools import groupby # 用于分组库。 # from os.path import splitext # 阅读全文
posted @ 2023-11-30 20:30 Danlis 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 第一种:打开xls的文件,报错,这个比较容易理解,就是openpyxl是不支持打开xls文件的,版本太老了。推荐使用xlrd库。 ```python openpyxl.utils.exceptions.InvalidFileException: openpyxl does not support t 阅读全文
posted @ 2023-09-08 15:05 Danlis 阅读(863) 评论(0) 推荐(0) 编辑
摘要: 位置参数 > positional argument 关键字参数 > keyword argument > 参数名=参数值 关键字参数一定在位置参数后面 ```python # *args > 可变参数 > 可以接收零个或任意多个位置参数 > 将所有的位置参数打包成一个元组 def add(*arg 阅读全文
posted @ 2023-09-06 16:00 Danlis 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 写程序的终极原则:高内聚,低耦合 > high cohesion low coupling 设计函数最为重要的原则:单一职责原则(一个函数只做好一件事情) > 高度内聚 模块调取隐藏判定:if __name__ == '__main__': 输入main一回车就会出现下面这个代码if __name_ 阅读全文
posted @ 2023-09-06 15:02 Danlis 阅读(8) 评论(0) 推荐(0) 编辑
摘要: # terminal停止的快捷键 **CTRL+C** ```python import os import time # example1 跑马灯文字效果 content = '拼搏到无能为力, 坚持到感动自己。' # content = '搏到无能为力, 坚持到感动自己。拼' # content 阅读全文
posted @ 2023-09-04 10:11 Danlis 阅读(36) 评论(0) 推荐(0) 编辑
摘要: # 字符串 ```python """ example05 - 字符串 1.转义问题 2.字符编码 Author: danlis Date: 2023/9/2 """ a = 'hello, world' # 和a一样的 b = "hello, world" # 一般长字符串,用三个单引号。三个双引 阅读全文
posted @ 2023-09-02 15:40 Danlis 阅读(14) 评论(0) 推荐(0) 编辑
摘要: # 获取ASCII码以及根据ASCII码获取内容 ```python # 获取字符的编码为98 # c的ASCII码为99 print(ord('c')) # chr()根据编获取对应的值 print(chr(99)) ``` # 十进制转换为其他进制 ```python # hex函数十进制转十六 阅读全文
posted @ 2023-09-02 15:12 Danlis 阅读(94) 评论(0) 推荐(0) 编辑
摘要: ```python """ example04 - 初步学习Python 1.学习元组tuple 2.元组的应用 Author: danlis Date: 2023/9/2 """ # START1 学习元组tuple # 元组是不可变的容器* # str = (100) # 这实际上class ' 阅读全文
posted @ 2023-09-02 14:15 Danlis 阅读(10) 评论(0) 推荐(0) 编辑
摘要: **Typora初步认识(markdown格式)** # **无序排列** “-”加空格 # **图片保存问题**: 左上方文件=》偏好设置=》图像=》一般选择“复制图片到./${filename}.assets文件夹”。这个地址使用的时候,也可以采取相对路径。"/${filename}.asset 阅读全文
posted @ 2023-09-02 12:24 Danlis 阅读(29) 评论(0) 推荐(0) 编辑
摘要: # Python初级学习20230901 运算符 >优先级和结合性 左结合:从左往右进行计算(大部分运算符) 右结合:从右往左进行计算(赋值运算符,正负号,索引和切片) ## assert断言语句 ``` python a = 1 assert a == 1 # 后面可以不加 assert a == 阅读全文
posted @ 2023-09-02 12:11 Danlis 阅读(13) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 23 下一页