会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
魂~
博客园
首页
新随笔
联系
管理
订阅
随笔分类 -
python 模块
python 模块Example链接
摘要:链接地址
阅读全文
posted @
2018-01-22 12:32
魂~
阅读(360)
评论(0)
推荐(0)
python random模块
摘要:1 import random 2 3 print(random.random()) # [0, 1),浮点数 4 print(random.uniform(1, 10)) # [1, 10]浮点数 5 print(random.randrange(1, 10)) # 不包括10 6 print(random.randi...
阅读全文
posted @
2018-01-22 12:16
魂~
阅读(190)
评论(0)
推荐(0)
python configparser模块
摘要:1 import configparser 2 3 4 """ 5 sections() 返回所有的section 6 has_section(section) 判断是否有指定的section 7 has_option(section, option) 判断是否有指定的section中的option 8 options(section) 返回指定section中的所有opti...
阅读全文
posted @
2018-01-22 10:25
魂~
阅读(448)
评论(0)
推荐(1)
python unittest模块
摘要:1 import unittest 2 import random 3 4 5 class Operation(object): 6 7 def __init__(self, num1=0, num2=0): 8 if not (0 <= num1 <= 10 and 0 <= num2 <= 10): 9 raise Ou...
阅读全文
posted @
2018-01-19 15:47
魂~
阅读(331)
评论(0)
推荐(0)
python timeit模块
摘要:1 import timeit 2 import math 3 4 5 def myfun(): 6 for i in range(100): 7 for j in range(2, 10): 8 math.pow(i, 1/j) 9 10 timeitObj = timeit.Timer(stmt=myfun) 11 t1...
阅读全文
posted @
2018-01-19 14:32
魂~
阅读(266)
评论(0)
推荐(0)
python datetime模块
摘要:1 import time 2 import datetime 3 4 """ 5 datetime模块用于是date和time模块的合集,datetime有两个常量,MAXYEAR和MINYEAR,分别是9999和1. 6 datetime模块定义了5个类,分别是 7 1.datetime.date:表示日期的类 8 2.datetime.datetime:表...
阅读全文
posted @
2018-01-19 14:09
魂~
阅读(1258)
评论(0)
推荐(0)
python time模块
摘要:1 import time 2 3 # 2种表示时间的方法: 4 # (1)时间戳,从1970.1.1开始 5 # (2)一个9个整数的元组 6 # 这个元组内容: 7 # year (including century, e.g. 1998) 8 # month (1-12) 9 # day (1-31) 10 ...
阅读全文
posted @
2018-01-18 17:04
魂~
阅读(404)
评论(0)
推荐(0)
python socket模块
摘要:1 import socket # module 2 import threading 3 import time 4 5 """ 6 FUNCTIONS 7 create_connection(address, timeout=, source_address=None) 8 Connect to *address* and retu...
阅读全文
posted @
2018-01-18 15:48
魂~
阅读(3110)
评论(0)
推荐(0)
python csv模块
摘要:1 import csv # Comma Separated Value 2 3 # class Dialect 4 # delimiter = None # 分隔符 5 # doublequote = None # 元素是引用符,双倍的引用符。默认是true,如果改为false就需要设置分隔符,否则报错。 6 # ...
阅读全文
posted @
2018-01-17 16:36
魂~
阅读(804)
评论(0)
推荐(0)
python pickle模块
摘要:1 import pickle 2 3 # 在python中如果我们有一些对象需要持久性存储,并且不丢失我们这个对象的类型与数据, 4 # 我们则需要将这些对象进行序列化,序列化后,需要使用的时候,我们在回复为原来的数据, 5 # 序列化的这种过程,我们将其称为pickle(腌制) 6 7 8 # 1、dumps(object) python对象 --> ...
阅读全文
posted @
2018-01-17 14:38
魂~
阅读(408)
评论(0)
推荐(1)
python struct模块
摘要:1 import struct # a module 2 3 4 # Functions to convert between Python values and C structs. 5 # Python bytes objects are used to hold the data representing the C struct 6 # and also as form...
阅读全文
posted @
2018-01-17 12:42
魂~
阅读(524)
评论(0)
推荐(0)
python threading模块
摘要:1 # http://www.runoob.com/python3/python3-multithreading.html 2 # https://docs.python.org/3/library/threading.html 3 # http://yoyzhou.github.io/blog/2013/02/28/python-threads-synchronization-lo...
阅读全文
posted @
2018-01-17 11:16
魂~
阅读(349)
评论(0)
推荐(0)
python queue模块
摘要:1 import queue 2 # queue - A multi-producer, multi-consumer queue. 3 # ['Empty', Exception raised by Queue.get(block=0)/get_nowait() 4 # 'Full', Exception raised by Queue.put(block=0)/put_nowait...
阅读全文
posted @
2018-01-16 14:56
魂~
阅读(325)
评论(0)
推荐(0)
python3 requests模块 基本操作
摘要:1 import requests 2 import json 3 4 5 # 1、HTTP方法 6 requests.get('https://github.com/timeline.json') #GET请求 7 requests.post('http://httpbin.org/post') #POST请求 8 request...
阅读全文
posted @
2018-01-16 11:52
魂~
阅读(584)
评论(0)
推荐(0)
python json模块
摘要:1 import json 2 3 # json.dumps 用于将 Python 对象编码成 JSON 字符串。 4 print(json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])) 5 print(type(json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]))) 6 7 # json....
阅读全文
posted @
2018-01-16 10:51
魂~
阅读(230)
评论(0)
推荐(0)
python re模块
摘要:一、单字符匹配 二、表示数量 三、表示边界 四、分组 五、标志 A = <RegexFlag.ASCII: 256> ASCII = <RegexFlag.ASCII: 256> DOTALL = <RegexFlag.DOTALL: 16> I = <RegexFlag.IGNORECASE: 2
阅读全文
posted @
2018-01-12 15:39
魂~
阅读(660)
评论(0)
推荐(0)
公告