摘要:
最大几个数和最小几个数 import heapq a = [7, 5, 3, 4, 8, 6, 0] cc = heapq.nsmallest(2, a) #最小的两个数 dd = heapq.nlargest(3, a) #最大的三个数 print(cc) # [1, 2] print(dd) # 阅读全文
posted @ 2020-12-09 14:32
rm-rf*
阅读(602)
评论(0)
推荐(0)
摘要:
命名切片 c = slice(2, 5) a = [1, 2, 3, 4, 5, 6, 7] print(a[c]) 阅读全文
posted @ 2020-12-09 14:30
rm-rf*
阅读(124)
评论(0)
推荐(0)
摘要:
git相关命令 基本操作 git init git add xxx git commit -m "first commit" git tag -a V1.0 -m '我的标签' git remote add origin git@github.com:xxx/spider.git 建立远程仓库连接 阅读全文
posted @ 2020-12-09 14:28
rm-rf*
阅读(244)
评论(0)
推荐(0)
摘要:
python解析命令行参数 import click @click.command() # 使函数解析命令行 @click.option("--id", help="用户名") # 命令行添加参数 def delete(id): """ 删除用户 :param id: :return: """ cl 阅读全文
posted @ 2020-12-09 14:27
rm-rf*
阅读(208)
评论(0)
推荐(0)
摘要:
数据可视化 使用pyecharts API文档 import math from pyecharts import options as opts from pyecharts.charts import Surface3D from pyecharts.globals import ThemeTy 阅读全文
posted @ 2020-12-09 14:26
rm-rf*
阅读(198)
评论(0)
推荐(0)
摘要:
为什么不能用可变对象作为默认参数的值 看一个例子 def abc(a, b): b.append(a) print(b) return b if __name__ == '__main__': abc(1, []) abc(2, []) abc(3, []) 结果和预期的一样: [1] [2] [3 阅读全文
posted @ 2020-12-09 14:25
rm-rf*
阅读(191)
评论(0)
推荐(0)
摘要:
Python 表达式 i += x 与 i = i + x 等价吗? 看个例子 a = [1, 2, 3] b = a # 写法一 b += [4] # 写法二 # b = b + [4] print(id(a), a) print(id(b), b) 两种不同的写法,结果不一致 写法一结果: 23 阅读全文
posted @ 2020-12-09 14:24
rm-rf*
阅读(169)
评论(0)
推荐(0)
摘要:
Python的数据缓存 python 的内置数据类型,数值型,字符串,列表,字典等都会有自己的对象缓存池, 这样做的好处是,避免了频繁的申请内存,释放内存,这样会极大的降低应用程序的运行速度,还会造成大量的内存碎片。因此提供对象缓存机制是非常重要的。 在Python中,字符串和整型对象都是不可变的( 阅读全文
posted @ 2020-12-09 14:23
rm-rf*
阅读(1584)
评论(2)
推荐(0)
摘要:
安装scrapy centos 7 安装scrapy报错说找不到scrapy需要的Twisted13.0以上版本? Collecting Twisted>=13.1.0 (from Scrapy) Could not find a version that satisfies the require 阅读全文
posted @ 2020-12-09 14:22
rm-rf*
阅读(105)
评论(0)
推荐(0)
摘要:
异步调用(坑) from concurrent.futures import ThreadPoolExecutor executor = ThreadPoolExecutor(5) def review(): '''省略过程''' #异步提交任务 executor.submit(call_crawl 阅读全文
posted @ 2020-12-09 14:21
rm-rf*
阅读(115)
评论(0)
推荐(0)

浙公网安备 33010602011771号