摘要:
class Test: _parent1 = 'variable parent' #父类成员变量首先被初始化 print(_parent1) _son_son = 'search parent' def __init__(self): print(self) #实际对应的实例化对象这里为 Test2 的实例 print('pare... 阅读全文
摘要:
import logging #创建日志文件 file = './test123.log' logger = logging.getLogger('test') #设置日志等级 logger.setLevel(logging.INFO) #添加文件输出流 filehanle = logging.FileHandler(file, mode='a') #设置日志输出格式 formatter ... 阅读全文
摘要:
# _*_coding:utf-8_*_ # author:leo # date: # email:alplf123@163.com from PyQt5.QtWidgets import QApplication, QMainWindow, QTextEdit, QWidget, QVBoxLayout, QFrame from PyQt5.Qt import QSize import sy... 阅读全文
摘要:
from optparse import OptionParser parser = OptionParser() parser.add_option('-f', '--file', dest='filename', help='test') # action 指定目的dest 存储的默认值 有时候参数不是必须的就可以设置action类型的默认值例如 true, false等 #常用的有 st... 阅读全文
摘要:
from PyQt5.QtCore import * from PyQt5.QtWidgets import * from PyQt5.Qt import * import sys class CustomToolBar(QToolBar): def __init__(self, parent=None): super(CustomToolBar, self).__... 阅读全文
摘要:
class Example(QMainWindow): def __init__(self, parent=None): super(Example, self).__init__(parent=parent) self._initUI() def _initUI(self): self.toolBar = QToolBar()... 阅读全文
摘要:
def handle(func): def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except Exception as e: print('sfdsd') return wrapper @handle #捕获异常,后面... 阅读全文
摘要:
import asyncio, threading import aiohttp class Tasks(): def __init__(self, max_async, loop=None): self.loop = loop or asyncio.get_event_loop() self._queue = asyncio.Queue(maxs... 阅读全文
摘要:
# _*_coding:utf-8_*_ # author:leo # date: # email:alplf123@163.com import queue, threading class Worker(threading.Thread): def __init__(self): threading.Thread.__init__(self) s... 阅读全文
摘要:
#装饰器小技巧一信号量控制 import threading, time NUM = 10 # 定义信号量控制 def synchronized(func): func.__sem__ = threading.Semaphore(value=NUM) print(func.__sem__) def wraper(*args, **kwargs): #支持... 阅读全文