分类: Python

9 篇文章

thumbnail
【Python小工具】从BeatSaber歌单文件夹中提取自己喜欢的歌曲
最近搬运了大佬的226G BeatSaber曲包,附上链接 https://share.wgzeyu.vip 但是曲包文件过大,非常冗余,导致每次进入游戏加载曲包文件夹要很久,于是写了这个小工具。 用途是从茫茫曲海中选择自己个人歌单里有的歌曲,选出自己喜欢的歌曲,并提取到一个文件夹里,做成一个独立的属于自己的曲包。     食用…
thumbnail
Python面向对象扫盲
'''面向对象扫盲''' #class info: #经典类的定义 class QiongB(object): #新式类的定义,object是基类,所有类继承object类 nation = 'zh' #类变量,相比实例变量,在实例化对象的过程中不需要开辟额外的内存。在大批量调用相同变量的时候类变量会更加高效。 def __init__(self,…
thumbnail
Python常用内置模块
''' 模块的分类 1.标准库 2.开源模块 3.自定义模块 ''' ''' 内置模块之time、datetime time三种类型:时间戳(1970后经过的秒数) 格式化字符串(2018-12-30) struct_time(tuple) 时间戳→struct_time:gmtime,localtime struct_time→时间戳:mktim…
thumbnail
Python模块初识
''' 1.模块本质是.py文件 2.导入方法:import module01 import module01,mudule02 from module01 import * #从模块上导入所有变量和方法,不建议使用。from ... import ... 相当于把相对模块的内容粘贴到相应位置,有可能会产生覆盖和冲突 import module01…
thumbnail
Python函数&装饰器扫盲
'''函数扫盲''' '''函数式完成一个记录日志的小功能''' ''' def log(): import time time_format = '%Y-%m-%d %X' time_curren = time.strftime(time_format) with open('Log','a+') as log: log.write('%s lo…
thumbnail
Python 文件常用操作
'''文件读的基本操作''' #f = open('file01',encoding='utf-8') #定义文件句柄 #print(f.read()) #打印 #print(f.read(5)) #读取5个字符 #data = f.read() #data2 = f.read() #print(data) #print(f.tell()) #查看…
thumbnail
Python 字符串常用方法
string_test = "router \tospf 1" print(string_test.capitalize())#首字母大写 print(string_test.count('o',0,4))#记录一个区间内某字符出现的次数,区间为可选项 print(string_test.center(50,"-"))#居中打印,以'-'补全 pr…
thumbnail
Python 字典、集合常用方法
'''字典''' dict = { '01':'Apple', '02':'Samsung', '03':'Huawei', } #字典的创建 #print(type(dict)) #print(dict) #字典打印是无序的 #print(dict['02']) #dict['02'] = '三星' #改 #print(dict['02']) #…
thumbnail
Python 列表、元组常用方法
list = ['apple','samsung','huawei','oppo','vivo','xiaomi','onplus'] '''查询操作''' #print(list.__len__()) #打印长度 #print(list[0]) #输出第一个值 #print(list[1:3]) #切片,输出1-2两个值 #print(list[…