摘要: 查询 import pymysql if __name__ == '__main__': # 创建连接对象 con = pymysql.connect(host="localhost", port=3306, user="xxxx", password="xxxx", database="db1", 阅读全文
posted @ 2021-03-10 16:54 code-G 阅读(75) 评论(0) 推荐(0) 编辑
摘要: 一般形式 import re # 在helloworld中匹配hello # 返回匹配的obj对象 obj = re.match('hello','hello world') # 获取匹配结果 group(n)获取第n+1组所匹配的子串 pro = obj.group() print(pro) 匹配 阅读全文
posted @ 2021-03-10 16:21 code-G 阅读(58) 评论(0) 推荐(0) 编辑
摘要: complie(pattern[,flags]) 创建模式对象 search(pattern,string[,flags]) 在整个字符串中寻找模式,返回match对象或None match(pattern,string[,flags]) 从字符串的开始处匹配,返回match对象或None find 阅读全文
posted @ 2021-03-10 16:01 code-G 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 浅拷贝 from copy import * # 无论深浅拷贝都针对可变类型 num1 = 1 num2 = copy(num1) print(id(num1),id(num2)) # 数字。字符串,元组,都没有开辟新空间,都是指向同一个引用地址 list1 = [1,3,4,[1,2]] list 阅读全文
posted @ 2021-03-10 11:04 code-G 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 推导式创建生成器 genter = (i * 2 for i in range(3)) # value = next(genter) # print(value) # value = next(genter) # print(value) # value = next(genter) # print 阅读全文
posted @ 2021-03-10 10:54 code-G 阅读(69) 评论(0) 推荐(0) 编辑