随笔分类 - Python
摘要:f __name__ == '__main__': print('test211') alist = [1,2,3,4,5,6,7,8,9] blist = list(filter((lambda x:x%2==0),alist)) print(blist) clist = list(map((la
阅读全文
摘要:53.python类的继承与构造函数 # This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search ever
阅读全文
摘要:pycharm社区版下载方法pycharm-community-2023.3.2.exe https://www.jetbrains.com.cn/ pycharm-community-2023.3.2.exe
阅读全文
摘要:52.python收集参数 def print_params(*params): # *接受元组,一个星号 print(params) def print_params2(tt2, *params): # *接受元组 print(tt2) print(params) def print_params
阅读全文
摘要:employee就是包 导入包,使用时默认调用__init__.py文件 class Employee: __wwid = '' # 两个__下划线表示private私有变量 __name = '' wwid = 'cd987' # public公有变量 def set_wwid(self, wwi
阅读全文
摘要:50.读取ini配置文件与使用日志模块logging记录日志信息保存日志文件 dept.ini [robots] fxl: L223 ttw: L856 ssy: M398 result_msg: this is ini file pii:3.625412 [visions] ll:k566 zel
阅读全文
摘要:mail_list = '123<aa2@163.com>acdef, 123123;<ba1@qq.com>acdef,;w8<aah@163.com>acdef,;dtg<ca@186.com>acdef,;jjdtg<qd@163.com>acdef,;jjtr' print('提取所有邮件地
阅读全文
摘要:Python 正则表达式(RegEx) 在本教程中,您将学习正则表达式(RegEx),并使用Python的re模块与RegEx一起使用(在示例的帮助下)。 正则表达式(RegEx)是定义搜索模式的字符序列。 例如, ^a...s$ 上面的代码定义了RegEx模式。模式是:以a开头并以s结尾的任何五个
阅读全文
摘要:this = chr(ESCAPES[this][1])KeyError: '\\e' re.error: bad escape \e at position 7 错误 正确: 翻译 搜索 复制
阅读全文
摘要:在Python中,脱字符号只在Windows的命令行shell中有效,如果在IDLE或其他文本编辑器中,脱字符号会被忽略,直接当成普通字符处理 要指定排除字符集,可在开头添加一个^字符,例如'[^abc]'与除a、b和c外的其他任何字符都匹配。 翻译 搜索 复制
阅读全文
摘要:Python 获取当前时间 本文中,您将学习获取语言环境的当前时间以及Python中的不同时区。 您可以采用多种方法获取Python当前时间。 示例1:使用datetime对象的当前时间 from datetime import datetime now = datetime.now() curre
阅读全文
摘要:Python Global 关键字 全局关键字简介 在Python中,global关键字允许您在当前作用域之外修改变量。它用于创建全局变量并在局部上下文中对该变量进行更改。 全局关键字规则 Python中global关键字的基本规则是: 当我们在函数内部创建变量时,默认情况下它是局部的。 当我们在函
阅读全文
摘要:Python range() 使用方法及示例 range(start, stop[, step]) 中括号含义:[,step]是第三个参数,可选项 参考 range()参数 range()主要采用三个在两个定义中具有相同用法的参数: start -整数,从该整数开始返回整数序列 stop-要返回整数
阅读全文
摘要:42.python json模块字符串操作_读取写入文件_对象转json字符串转对象相互转换 # This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press
阅读全文
摘要:python shelve模块写入dat文件保存数据库 # This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to se
阅读全文
摘要:python堆、集合、双端队列 # This is a sample Python script. # 1# 1 # 2# 2 # Press Shift+F10 to execute it or replace it with your code.# 3# 3 # Press Double Shi
阅读全文
摘要:39.python list列表的操作 if __name__ == '__main__': #13#13 #print_hi('PyCharm') #14#14 import fileinput #15#15 #for line in fileinput.input(inplace=True):
阅读全文
摘要:# This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes,
阅读全文
摘要:最外面的引号是由Python本身使用的,而Windows shell看不到它,Windows只理解双引号。 Python将在Windows上将正斜杠转换为反斜杠,因此您可以使用 exe_path = r'C:\Windows\System32\mspaint.exe' exe_path2 = r'"
阅读全文
摘要:if __name__ == '__main__': #print_hi('PyCharm') add_to_log_func('abcdefg') print("read_content:\n", read_file_func()) msg = input('key key for exit...
阅读全文