![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python基础
Harold_96_lxw
蛰伏,打磨技术,厚积薄发
展开
-
Python 列表嵌套字典的数据排序
Python 列表嵌套字典的数据排序1、相关代码针对data[‘data’][‘list’]部分进行排序def test(): data = {"message": "OK", "code": "0", "data": {"totalRecords": 7, "device": "influxdb", "list": [ {"ip": "10.32.7.186", "_in_use": 25.005804979490698, "time": 1630026435000},原创 2021-08-27 09:38:39 · 78599 阅读 · 0 评论 -
Centos7在Python3下virtualenv创建虚拟python环境
Centos7在Python3下virtualenv创建虚拟python环境1、安装virtualenvpip3 install virtualenv -i https://pypi.douban.com/simple2、切换工作目录并创建项目空文件夹cd /home/servermkdir Testcd Test3、创建python虚拟环境virtualenv --python=python3 venv4、启动虚拟环境source venv/bin/activate5、安装依原创 2021-06-03 17:32:07 · 97644 阅读 · 0 评论 -
Python xlrd操作表格
Python xlrd操作表格1、安装xlrd库pip install xlrd==1.2.02、读取工作簿单元格def Read_Bk_Ip(filename): data = xlrd.open_workbook(filename) sheet1 = data.sheets()[0] nrows = sheet1.nrows ncols= sheet1.nclos for i in nrows: for j in ncols: da原创 2021-05-19 15:45:56 · 99402 阅读 · 0 评论 -
python3中子类给父类私有属性赋值时遇到的坑
题目是这样的: 有2个类 A 和B,A是父类、B是子类 A中有私有属性a=None 现在子类要给父类中的私有属性a赋新值 我一开始是这样写的:class A(): def __init__(self): self.__a=None @property def a(self): return self.__a @a.se...原创 2018-09-10 20:32:21 · 49200 阅读 · 2 评论 -
python多线程问题,模拟抢退票过程
import timeimport threadingimport randomtickets=500condition=threading.Condition()class buy(threading.Thread): def __init__(self,threadname): threading.Thread.__init__(self) ...原创 2018-09-13 19:48:22 · 46772 阅读 · 0 评论 -
python简单的人机问答(多线程)
import threading,time,randomcondition=threading.Condition()problems={ 'name':'My name is skynet' ,'age':"I am 8 years old" ,'hobby':'My hobby is Nature Language Processing' ,'sex':'...原创 2018-09-13 19:50:37 · 47188 阅读 · 0 评论