随笔分类 -  Python

摘要:解决方法: cmd中敲命令:python -m ensurepip 阅读全文
posted @ 2022-06-29 13:55 opscool 阅读(27) 评论(0) 推荐(0) 编辑
摘要:阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(douban) http://pypi.douban.com/simple/ 清华大学 https://pypi 阅读全文
posted @ 2022-06-29 13:53 opscool 阅读(86) 评论(0) 推荐(0) 编辑
摘要:dict,pop('key') 删除某个键值对,并返回value值 dict = {} 清空字典 del dict 删除字典 阅读全文
posted @ 2022-06-29 13:51 opscool 阅读(142) 评论(0) 推荐(0) 编辑
摘要:例:有a、b两个列表 a = [1, 2, 3] b = [4, 5, 6] 1、调用zip函数 c = zip(a, b) 输出结果 c = [(1, 4), (2, 5), (3, 6)] 2、调用zipped函数 d = zipped(c) 输出结果 d = [(1, 2, 3), (4, 5 阅读全文
posted @ 2022-06-29 13:50 opscool 阅读(68) 评论(0) 推荐(0) 编辑
摘要:data = [(“a”, “1”), (”a“, ”2“), (”b“, ”3“)] d2 = {} for k, v in data: d2.setdefault(k, []).append(v) print(d2) 注:setdefault方法会先判断d2这个字典中是否存在k这个键,如果存在就 阅读全文
posted @ 2022-06-29 13:46 opscool 阅读(114) 评论(0) 推荐(0) 编辑
摘要:注:此模块将python代码打包后在windows上可直接双击运行 1、从豆瓣安装pyinstaller pip install -i https://pypi.douban.com/simple/ pyinstaller 2、例子: pyinstaller -F demo.py 会在当前目录下生成 阅读全文
posted @ 2022-06-29 13:42 opscool 阅读(104) 评论(0) 推荐(0) 编辑
摘要:1、cd /usr/lib64/python2.7/site-packages 2、vim tab.py #/usr/bin/env python #_*_encoding:utf-8_*_ try: import readline except ImportError: print("Module 阅读全文
posted @ 2022-06-29 13:32 opscool 阅读(16) 评论(0) 推荐(0) 编辑
摘要:定义: 1、本质是函数 2、功能是装饰其他函数,为其他函数添加附加功能 原则: 1、不能修改被装饰的函数的源代码 2、不能修改被装饰的函数的调用方式 阅读全文
posted @ 2022-06-29 13:31 opscool 阅读(15) 评论(0) 推荐(0) 编辑
摘要:生成器只有在调用的时候才会生成相应的数据 只记录当前的位置 python2.X用的next()方法,python3.X用__next__方法或者next(func) next会调用yield send在调用yield的时候还会传值 阅读全文
posted @ 2022-06-29 13:30 opscool 阅读(12) 评论(0) 推荐(0) 编辑
摘要:abs() 求绝对值 all() 判断是否都为真,如all([1,2,-1])返回True,all([1,2,0])返回False any() 判断是否存在真,如any([1,2,0])返回True bin() 数字转为二进制 chr() 返回ascii码 ord() 与chr相反 dir() 返回 阅读全文
posted @ 2022-06-29 13:29 opscool 阅读(19) 评论(0) 推荐(0) 编辑
摘要:1.安装依赖 yum install epel-release 2.安装python3 yum install python36 阅读全文
posted @ 2022-06-29 13:24 opscool 阅读(13) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示