
python
unique碎
uniquexiaohou
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python 多线程编程(一个经典例子)
python 多线程经典案例(摘自《python核心编程》) 使用队列的数据结构,生产者生产商品,消费者选取商品,且时间均不固定from random import randintfrom time import sleepfrom queue import Queuefrom threading import Threadclass ThreadFunc(Thread): def转载 2016-10-12 00:33:13 · 2231 阅读 · 0 评论 -
python 命令行解析工具 argparse 基本使用
parser = argparse.ArgumentParser() #创建对象 parser.add_argument("file") #添加参数 parser.add_argument("-o", "--output") parser.add_argument('--width', type=int, default=80) #添加可选参数,并规定类型、默认值原创 2016-11-13 09:59:57 · 448 阅读 · 0 评论 -
python 标准输入输出流
python 中有三种标准输入输出流:sys.stdin、sys.stdout、sys.error>>> f = open("1.txt", "r")# fileno方法可返回整数的底层实现使用请求从操作系统的I/O操作的文件描述符(可理解为是第几个打开的文件)>>> f.fileno()3#一般打开的第一个文件是第三个,前3个(从0开始)为三个标准输出流>>> sys.stdin.fil原创 2016-11-13 23:58:06 · 7934 阅读 · 0 评论 -
python ini配置文件处理
一 ini 配置文件格式 节: [session] 参数: 键=值 name = value 例子: [port] port1 = 8080 port2 = 6060 二 ConfigParser 库>>> import configparser>>> cfg = configparser.Conf原创 2016-11-14 19:03:31 · 4925 阅读 · 0 评论 -
Python 函数
一、hypot:返回欧几里德范数(sqrt(x*x + y*y))>>> from math import hypot>>> hypot(3,4)5.0原创 2017-11-24 09:51:04 · 327 阅读 · 0 评论 -
Python 库、技巧
一、namedtuple:用于构建只有少数属性但无方法的对象>>> from collections import namedtuple>>> Card = namedtuple('Card', ['rank', 'suit'])>>> card = Card(5, 'hearts')>>> cardCard(rank=5, suit='hearts')原创 2017-11-24 09:54:32 · 339 阅读 · 0 评论 -
Python 技巧
一、%r:可替代 %s、%d 等>>> s = 'abc'>>> i = 1>>> '%r is %r' % (s, i)"'abc' is 1">>> '%r is %r' % (i, s)"1 is 'abc'"原创 2017-11-24 09:47:57 · 257 阅读 · 0 评论 -
pip install 中的一些错误
pip install 中的一些错误首先会有c++14.0 的问题,这个没什么可说的,直接装就好了。问题一在安装 wechat-sdk 时遇到一个错误Command "e:\python\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\XINZW_~1\\AppData\\Local\\Temp\\pi...原创 2019-04-04 18:01:41 · 1150 阅读 · 0 评论