10.标准库简介

1.操作系统接口

import os
os.getcwd()
os.chdir('')#切换当前工作目录
os.system('mkdir today')#执行命令
dir(os)
help(os)

import shutil

2.文件通配符

  • glob模块提供了一个在目录中使用通配符搜索创建文件列表的函数

3.命令行参数

import sys
print(sys.argv)

4.错误输出重定向和程序终止

stdin、stdout、stderr

5.字符串模式匹配

re模块
'one and too'.replace('too','two')
=》'one and two'
import re
re.findall
re.sub

6.数学

import math
math.cos(math.pi/4)
math.log(1024,2)

import random
random.choice([2,4,1])

选一个

random.sample(range(100),10)

抽样,抽10个

import statistics
data=[1,2,4,7,3]
statistics.mean(data)#算术平均
statistics.median(data)#中位数
statistics.variance(data)#方差

7.互联网访问

urllib.request用于从URL检索数据
smtplib用于发送邮件

8.日期和时间

from datetime import date
now=date.today()

9.数据压缩

import zlib

10.性能测量

from timeit import Timer
Timer('代码').timeit()

11.质量控制

  • doctest模块用于扫描模块并验证程序文档字符串中嵌入的测试
    doctest.testmod()
  • uinttest模块

12.自带电池

  • xmlrpc.client\xmlrpc.server
  • email
  • json
  • sqlite3
  • xml.etree.ElementTree
  • xml.dom
  • xml.sax
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值