10 2019 档案
摘要:# 在学习LXML库的时候遇到了一个问题lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 4 and head, line 6, column 8 百度发现这是由于自己html代码书写不规范,不符合xml解析器
阅读全文
摘要:# coding=utf-8"""自定义一个类,继承Process类,同时重写run()方法"""# 导入模块from multiprocessing import Processimport time# 创建类class ClockProcess(Process): # 重写初始化方法 def __init__(self, interval): # 初始化父类方法 Process.__init_
阅读全文
摘要:# 爬取糗事百科项目 由于该网站正在维护 我只是按照已经能够爬取出来的html代码手动观察修改正则表达式的内容 # 代码 # 函数解析 re.findall(pattern, string, flags=0) 通过使用该函数可以匹配所有符合查询规律的内容 通过查询API文档可以发现 pattern是
阅读全文
摘要:# coding=utf-8"""1.导入模块sqlite32.创建连接 sqlite3.connect()3.创建游标对象4.编写创建表的sql语句5.执行sql6.关闭连接"""import sqlite3# 创建连接con = sqlite3.connect("E:/sqlite3Demo/d
阅读全文
摘要:在python中声明全局变量可以使用关键字global,那么如何声明方法级之间的变量就需要用到nonlocal
阅读全文
摘要:random.seed() 随机数种子 通过借助seed函数 我们可以每次生成相同的随机数 # 代码 我们可以看到通过随机数种子seed函数的约束 我们每一次在相同种子约束下生成的随机数都是相同的
阅读全文
摘要:# coding=utf-8"""请输入10个数,并安从小到大的顺序排序"""num = []def getTenNum(): for i in range(10): x = int(input("please input the num:")) num.append(x)def sortNum(n
阅读全文
摘要:# coding=utf-8"""输出指定区间的素数"""num = []lower = int(input("please input the low num"))higher = int(input("please input the high num"))def ifSuNum(n): if
阅读全文