摘要: 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 我是外婆 阅读(2489) 评论(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 我是外婆 阅读(319) 评论(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 我是外婆 阅读(7455) 评论(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 我是外婆 阅读(143) 评论(0) 推荐(0) 编辑
摘要: #自定义异常 需要继承Exception class MyException(Exception): def __init__(self, *args): self.args = args #raise MyException('爆出异常吧哈哈') #常见做法定义异常基类,然后在派生不同类型的异常 class loginError(MyException): ... 阅读全文
posted @ 2018-01-11 17:09 我是外婆 阅读(12498) 评论(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 我是外婆 阅读(103) 评论(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 我是外婆 阅读(201) 评论(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 我是外婆 阅读(112) 评论(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 我是外婆 阅读(480) 评论(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 我是外婆 阅读(421) 评论(0) 推荐(0) 编辑