python
文章平均质量分 56
le0chang
这个作者很懒,什么都没留下…
展开
-
python执行超时退出
eventletimport timeimport eventlet #导入eventlet这个模块eventlet.monkey_patch() #必须加这条代码with eventlet.Timeout(2,False): #设置超时时间为2秒 print '这条语句正常执行' time.sleep(4) print '没有跳过这条输出'print '跳过了输出'问题:1、针对子进程无法跳出timeout_decoratorfrom tqdm import原创 2021-10-26 11:16:20 · 3591 阅读 · 1 评论 -
Django配置MySQL数据库
1、安装pip3 install pymysql2、配置init.py文件打开项目根目录下的_init__.py文件,添加以下内容:import pymysqlpymysql.install_as_MySQLdb()3. 配置settings.py中的MySQL配置DATABASE = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME':原创 2021-08-13 15:41:54 · 99 阅读 · 0 评论 -
Django 使用 bootstrap
一、下载Bootstrap 中文网:http://www.bootcss.com/Bootstrap Table 官网:https://bootstrap-table.com/JQuery 官网:https://jquery.com/在bootstrap中文网下载第一个就好 第二个是包含一些网页实例的 合集包二、配置1、新建static文件夹首先在项目目录下(与models.py同级)新建文件夹 static 用来 放置 bootstrap 的 css/js/font文件2、修改settin原创 2021-07-27 10:30:57 · 1118 阅读 · 0 评论 -
python 正则
一、re.complie1.1 介绍re模块中有re.match、re.serch、re.findall,也是最常用的re.compile()是用来优化正则的,它将正则表达式转化为对象,re.search(pattern, string)的调用方式就转换为 pattern.search(string)的调用方式,多次调用一个正则表达式就重复利用这个正则对象,可以实现更有效率的匹配re.compile()语法格式如下:compile(pattern[,flags] ) pattern : 一个字原创 2021-07-26 19:23:34 · 253 阅读 · 0 评论