摘要: 路径的拼接 import os​path = os.path.join("db", 'root', "a.txt")print(path) 上级目录 import os​path = os.path.join("db", 'root', "a.txt")print(path) # db/root/a 阅读全文
posted @ 2023-06-21 10:19 壮九 阅读(10) 评论(0) 推荐(0)
摘要: content = li.xpath('./div[1]/text()').extract_first() title = li.xpath('./div[2]/a/text()').extract_first() all_data = title+content #生成该数据的数据指纹 impor 阅读全文
posted @ 2023-06-20 15:16 壮九 阅读(45) 评论(0) 推荐(0)
摘要: 迭代器 class Reader(object): """ 自定义异步迭代器(同时也是异步可迭代对象) """ def __init__(self): self.count = 0 def readline(self): # await asyncio.sleep(1) self.count += 阅读全文
posted @ 2023-05-31 16:30 壮九 阅读(14) 评论(0) 推荐(0)
摘要: 普通网络请求 import requests url_list = [ 'https://www3.autoimg.cn/newsdfs/g26/M02/35/A9/120x90_0_autohomecar__ChsEe12AXQ6AOOH_AAFocMs8nzU621.jpg', 'https:/ 阅读全文
posted @ 2023-05-31 16:13 壮九 阅读(27) 评论(0) 推荐(0)
摘要: 同步编程:用时大概4秒 import time import requests def download_image(url): print("开始下载:",url) # 发送网络请求,下载图片 response = requests.get(url) print("下载完成") # 图片保存到本地 阅读全文
posted @ 2023-05-29 00:03 壮九 阅读(42) 评论(0) 推荐(0)
摘要: import asyncio import time async def func1(): print(1) await asyncio.sleep(2) print(2) async def func2(): print(3) await asyncio.sleep(2) print(4) asy 阅读全文
posted @ 2023-05-28 23:20 壮九 阅读(542) 评论(0) 推荐(0)
摘要: 后台view: res={'1':2,'2':2,'3':3} for k,v in res.items: print (k,v) 前端html {%for k,v in res} {{v}}{%endfor}jquey中 $.each(res),function(k,v){ k,v} 阅读全文
posted @ 2023-05-27 20:24 壮九 阅读(9) 评论(0) 推荐(0)
摘要: 在前端页面时应该直接 对象.外键.变量 在后端视图函数中则应该用 对象.外键_id. 阅读全文
posted @ 2023-05-27 13:58 壮九 阅读(25) 评论(0) 推荐(0)
摘要: 一般情况下,点击弹窗确定发送时会没有反应, 1、可以f12查看你发送的ajax页面预览查看是否被阻止 2、用console.log(res)打印查看 function confirmAdd() { var data=$('#myForm').serialize(); var data = $("#m 阅读全文
posted @ 2023-05-27 01:09 壮九 阅读(48) 评论(0) 推荐(0)
摘要: 1、定义删除按钮及删除函数 <a class="btn btn-danger btn-xs" onclick="showDelete({{ obj.id }});">删除</a> 2,编写弹窗内容 选择bootstrap→js插件→模态框的动态实例:launch demo modal <!-- Mo 阅读全文
posted @ 2023-05-26 22:26 壮九 阅读(122) 评论(0) 推荐(0)