01 2018 档案

摘要:class PopMenu(QMenu): def __init__(self, parent=None): super().__init__(parent) self.item1 = self.addAction('item1') self.item1.setShortcut(Qt.CTRL | Qt.Key_Q) sel... 阅读全文
posted @ 2018-01-30 17:48 我是外婆 阅读(1476) 评论(0) 推荐(0)
摘要:from bs4 import BeautifulSoup from bs4.element import * data = """ beatifulsoup learning note i`m son1 哈哈 ... 阅读全文
posted @ 2018-01-29 11:25 我是外婆 阅读(284) 评论(0) 推荐(0)
摘要:from PyQt5.QtCore import * from PyQt5.QtWidgets import * from PyQt5.QtGui import * import sys class LineEditEx(QLineEdit): def __init__(self, parent=None): super().__init__(None, parent... 阅读全文
posted @ 2018-01-26 18:17 我是外婆 阅读(2525) 评论(0) 推荐(0)
摘要:常见的MIME类型(通用型): 超文本标记语言文本 .html text/html xml文档 .xml text/xml XHTML文档 .xhtml application/xhtml+xml 普通文本 .txt text/plain RTF文本 .rtf application/rtf PDF 阅读全文
posted @ 2018-01-26 16:25 我是外婆 阅读(342) 评论(0) 推荐(0)
摘要:from PyQt5.QtWidgets import * from PyQt5.QtGui import QStandardItemModel, QStandardItem from PyQt5.QtCore import QSize, QPoint, QRect, QModelIndex import sys class Example(QMainWindow): # 继承QMainWind... 阅读全文
posted @ 2018-01-22 18:27 我是外婆 阅读(7497) 评论(1) 推荐(0)
摘要:import tarfile import os, shutil filepath = 'd:/python project' ftarname = './test.tar.gz' tarlib = './test/' print(os.getcwd()) #==================gz压缩文件=================== # with tarfile.open(ftarn... 阅读全文
posted @ 2018-01-12 11:12 我是外婆 阅读(162) 评论(0) 推荐(0)
摘要:#自定义异常 需要继承Exception class MyException(Exception): def __init__(self, *args): self.args = args #raise MyException('爆出异常吧哈哈') #常见做法定义异常基类,然后在派生不同类型的异常 class loginError(MyException): ... 阅读全文
posted @ 2018-01-11 17:09 我是外婆 阅读(12762) 评论(0) 推荐(0)
摘要:import requests from requests import cookies # requests 更为强大,方便 url = 'http://www.baidu.com' session = requests.Session() #初始化一个session get,post,put session.headers = {} # 设置协议头 session.auth = () # ... 阅读全文
posted @ 2018-01-11 09:56 我是外婆 阅读(112) 评论(0) 推荐(0)
摘要:# _*_coding:utf-8_*_ # author:leo # date: # email:alplf123@163.com # python中的三目运算 # 常见的方式 is True ? val1:val2 # python中 a = 4 print(10 if a > 3 else 5) # 判断条件挪到if后面 满足条件返回前面的值,否则返回后面的值 #在生成式中的应... 阅读全文
posted @ 2018-01-10 00:04 我是外婆 阅读(208) 评论(0) 推荐(0)
摘要:# _*_coding:utf-8_*_ # author:leo # date: # email:alplf123@163.com from concurrent.futures import * from urllib import request import time import random tasks = [] def test(val): rand = random.r... 阅读全文
posted @ 2018-01-07 22:13 我是外婆 阅读(124) 评论(0) 推荐(0)
摘要:# _*_coding:utf-8_*_ # author:leo # date: # email:alplf123@163.com from collections import Iterable, Iterator class myIterator(): _data = None _count = 0 def __init__(self, data): ... 阅读全文
posted @ 2018-01-06 20:41 我是外婆 阅读(493) 评论(0) 推荐(0)
摘要:#coding:utf-8 import os import sys #当前环境py2.7 print(sys.getdefaultencoding()) #注意是编码方式,不是编码 #定义一个字符串 str = '中' #print(str) print(len(str)) #长度3, utf-8 #str.encode('gbk') #报错,当前编码环境为ascii 不能直接从ascii映射... 阅读全文
posted @ 2018-01-05 11:05 我是外婆 阅读(433) 评论(0) 推荐(0)
摘要:from queue import Queue from datetime import datetime import threading import os,sys q = Queue() fileprefix = 'test' def creator(): for i in range(1, 100): q.put_nowait(i) print(... 阅读全文
posted @ 2018-01-03 18:25 我是外婆 阅读(114) 评论(0) 推荐(0)
摘要:class Rules(): __spe__ = "special"#特殊变量 __private = 'private' #完全私有子类无法访问 _halfprivate = 'halfprivate' #只能在类中模块中使用 def _halfprivatefunc(self): print('half func') def __p... 阅读全文
posted @ 2018-01-03 10:31 我是外婆 阅读(125) 评论(0) 推荐(0)
摘要:# 多个重载 # 可以为string a = '我爱中国' b = bytes(a, encoding='gbk') print(b) # 可以为迭代对象 c = [1, 2, 3, 4] d = bytes(c) print(d) # 同时支持b e = b'sdfsdf' print(bytes(b)) #直接输出十六进制文本串,很方便 print(bytes(a, encoding='gb... 阅读全文
posted @ 2018-01-02 17:39 我是外婆 阅读(166) 评论(0) 推荐(0)
摘要:#coding:utf-8 import logging from logging import handlers import time #简单的不同级别日志输出 # logging.debug('this is debug msg') # logging.info('this is info msg') # logging.warning('this is warning msg') # l... 阅读全文
posted @ 2018-01-02 11:39 我是外婆 阅读(130) 评论(0) 推荐(0)