模块

用一坨代码实现了某个功能的代码集合

模块分为三种

· 自定义模块

· 第三方模块

· 内置模块

1)自定义模块

自己编写并存在在某个路径下的python程序,实现了某个功能,可以被其他程序调用

2)第三方模块

网络上下载并能兼容当前Python版本的第三方程序模块,比如支持HTTP测试的requests库

3)内置模块

C:\Python3.5\Lib目录下的py文件大部分都是Python的内置模块,如sys、os、time等

导入模块

1234

import modulefrom module.xx.xx import xxfrom module.xx.xx import xx as rename  from module.xx.xx import *

模块默认搜索路径

1234567891011121314151617

import sysfor item in sys.path:  # python系统路径    print(item)输出:C:\Python3.5\python.exe C:/software/github/Python/day5/s2.pyC:\software\github\Python\day5C:\Users\lilongzi\PycharmProjects\PythonC:\software\github\PythonC:\Python3.5\python35.zipC:\Python3.5\DLLsC:\Python3.5\libC:\Python3.5C:\Python3.5\lib\site-packagesC:\Python3.5\lib\site-packages\setuptools-27.2.0-py3.5.eggsys.path.append('E:\\')  # 添加系统路径

Python常用模块

1)序列化相关 json pickle (序列化是指将)

序列化是指将一个字符串转换成基础数据类型或者基础数据类型数据转换成字符串

json 用于【字符串】 和 【python基础数据类型】间进行转换

pickle 用于【python特有类型】 和 【python基础数据类型】间进行转换

json 和 pickle 都提供了四个功能: dumps、dump、loads、load

12345678910111213

import jsondic = {'k1': 'v1'}result = json.dumps(dic)  # 序列化 将python的基础数据类型转化成字符串形式print(result, type(result))s1 = '{"k1": 123}'dic1 = json.loads(s1)  # 反序列化 将字符串类型转换成python数据类型print(s1, type(dic1))输出{"k1": "v1"} {"k1": 123}

dump和load

12345678

json.dump(dic, open('test', 'w')) # 序列化之前,写入一个文件result = json.load(open('test', 'r')) # 读文件,再操作序列化print(result, type(result))输出{'k1': 'v1'}

json配合第三方requests模块获取天气API示例

12345678910111213

import requestsimport jsonresponse = requests.get('http://wthrcdn.etouch.cn/weather_mini?city=上海')response.encoding = 'utf-8'dic = json.loads(response.text)print(dic, type(dic))输出{'status': 1000, 'desc': 'OK', 'data': {'yesterday': {'low': '低温 19℃', 'fx': '东北风','high': '高温 21℃', 'date': '26日星期三', 'fl': '3-4级', 'type': '大雨'}}...

pickle

12345678910111213

import pickle# pickle 只能Python识别 不适用于别的语言li = [11, 22, 33]r = pickle.dumps(li)print(r)result = pickle.loads(r)print(result)输出:b'\x80\x03]q\x00(K\x0bK\x16K!e.' # 转换成了只有Python自己能识别的代码[11, 22, 33]

json/pickle 区别

12

# json更加适合跨语言 字符串 基本数据类# pickle 处理Python复杂类型的序列化 缺点是仅适用于Python

注意,单引号和双引号在反序列化中的差别

123456789

import jsonli = '["kobe", "jordan"]'  #  正确写法#li = "['kobe', 'jordan']" #  错误写法ret = json.loads(li)print(ret, type(ret))输出['kobe', 'jordan']

2)time模块

时间有三种表现形式

123456789

print(time.time())  # 时间戳print(time.strftime('%Y-%m-%d'))  # 格式化的字符串print(time.localtime())  # 结构化时间输出1477623310.3507262016-10-28time.struct_time(tm_year=2016, tm_mon=10, tm_mday=28, tm_hour=10, tm_min=55,tm_sec=10, tm_wday=4, tm_yday=302, tm_isdst=0)

常见time操作

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455

import timeprint(time.ctime())print(time.ctime(time.time()-86400))# 输出# Fri Oct 28 11:06:30 2016# Thu Oct 27 11:06:30 2016print(time.gmtime())time_obj = time.gmtime()print(time_obj.tm_year, time_obj.tm_mon, time_obj.tm_mday)print(time.mktime(time_obj))# 输出# time.struct_time(tm_year=2016, tm_mon=10, tm_mday=28, tm_hour=3, tm_min=12, tm_sec=44,# tm_wday=4, tm_yday=302, tm_isdst=0)# 2016 10 28# 1477595761.0# 将struct_time格式转换成指定格式print(time.localtime())print(time.strftime("%Y-%m-%d %H:%S", time.localtime()))# 与strftime相反 将字符串转换成strcut格式tm = time.strptime("2016-10-10 10:50", "%Y-%m-%d %H:%M")print(tm)# 输出# time.struct_time(tm_year=2016, tm_mon=10, tm_mday=28, tm_hour=11, tm_min=17,# tm_sec=30, tm_wday=4, tm_yday=302, tm_isdst=0)# 2016-10-28 11:30# time.struct_time(tm_year=2016, tm_mon=10, tm_mday=10, tm_hour=10, tm_min=50,# tm_sec=0, tm_wday=0, tm_yday=284, tm_isdst=-1)import datetimeprint(datetime.datetime.now())  # 显示当前时间print(datetime.date.today())print(datetime.date.fromtimestamp(time.time()-86400))  # 将时间戳转换成格式化日期# 时间加减print(datetime.datetime.now() + datetime.timedelta(days=10))  # 比现在加10天print(datetime.datetime.now() - datetime.timedelta(days=10))  # 比现在晚10天print(datetime.datetime.now() + datetime.timedelta(hours=10))  # 加10小时current_time = datetime.datetime.now()print(current_time.replace(2015, 10, 10))  # 直接替换时间print(datetime.datetime.strptime("09/10/15 11:40", "%d/%m/%y %H:%M"))# 输出# 2016-10-28 11:21:54.580869# 2016-10-28# 2016-10-27# 2016-11-07 11:21:54.580869# 2016-10-18 11:21:54.580869# 2016-10-28 21:21:54.580869# 2015-10-10 11:21:54.580869# 2015-10-09 11:40:00

时间转换图

格式样式

1234567891011121314

%Y  Year with century as a decimal number.    %m  Month as a decimal number [01,12].    %d  Day of the month as a decimal number [01,31].    %H  Hour (24-hour clock) as a decimal number [00,23].    %M  Minute as a decimal number [00,59].    %S  Second as a decimal number [00,61].    %z  Time zone offset from UTC.    %a  Locale's abbreviated weekday name.    %A  Locale's full weekday name.    %b  Locale's abbreviated month name.    %B  Locale's full month name.    %c  Locale's appropriate date and time representation.    %I  Hour (12-hour clock) as a decimal number [01,12].    %p  Locale's equivalent of either AM or PM.

3)logging模块

用于便捷记录日志和线程安全的模块

12345678910111213141516171819

import logging# 设置输出文件、文件格式和日志级别logging.basicConfig(filename='example.log', level=logging.INFO,                    format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')# 开始打印日志信息logging.debug('This message should go to the log file')logging.info('So should this')logging.warning('And this, too')logging.warning("user [kobe] attempted wrong password more than 3 times")logging.critical("Server is down...")# 输出example.log>>10/28/2016 01:12:14 PM So should this10/28/2016 01:12:14 PM And this, too10/28/2016 01:12:14 PM user [kobe] attempted wrong password more than 3 times10/28/2016 01:12:14 PM Server is down...

日志等级

12345678

CRITICAL = 50FATAL = CRITICALERROR = 40WARNING = 30WARN = WARNINGINFO = 20DEBUG = 10NOTSET = 0

日志记录格式

多文件记录日志

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849

# 1、创建logger 谁去发日志logger = logging.getLogger('TEST-LOG')  # 先获取logger对象logger.setLevel(logging.DEBUG)  # 设置全局日志级别# 2、创建Handler 发给屏幕ch = logging.StreamHandler()  # 在屏幕上打印ch.setLevel(logging.DEBUG)  # 设置在屏幕上打印日志的全局级别# 3、创建Handler 文件fh = logging.FileHandler("access.log")fh.setLevel(logging.WARNING)  # 日志局部级别fh_err = logging.FileHandler("error.log")fh_err.setLevel(logging.ERROR)# 4、创建formatter输出格式formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')formatter_for_file = logging.Formatter('%(asctime)s - %(filename)s - %(levelname)s - %(message)s')# 5、分别设置格式ch.setFormatter(formatter)fh.setFormatter(formatter_for_file)fh_err.setFormatter(formatter)# 6、向logger注册logger.addHandler(ch)logger.addHandler(fh)logger.addHandler(fh_err)# 7、打印logger.debug('debug message')logger.info('info message')logger.warn('warn message')logger.error('error message')logger.critical('critical message')屏幕输出:2016-10-28 13:20:13,656 - TEST-LOG - DEBUG - debug message2016-10-28 13:20:13,656 - TEST-LOG - INFO - info message2016-10-28 13:20:13,656 - TEST-LOG - WARNING - warn message2016-10-28 13:20:13,656 - TEST-LOG - ERROR - error message2016-10-28 13:20:13,657 - TEST-LOG - CRITICAL - critical message文件输出:access.log>>2016-10-28 13:20:13,656 - log.py - WARNING - warn message2016-10-28 13:20:13,656 - log.py - ERROR - error message2016-10-28 13:20:13,657 - log.py - CRITICAL - critical messageerror.log>>2016-10-28 13:20:13,656 - TEST-LOG - ERROR - error message2016-10-28 13:20:13,657 - TEST-LOG - CRITICAL - critical message

4)sys

用于对Python解释器相关操作:

sys.argv           命令行参数List,第一个元素是程序本身路径sys.exit(n)        退出程序,正常退出时exit(0)sys.version        获取Python解释程序的版本信息sys.maxint         最大的Int值sys.path           返回模块的搜索路径,初始化时使用PYTHONPATH环境变量的值sys.platform       返回操作系统平台名称sys.stdin          输入相关sys.stdout         输出相关sys.stderror       错误相关

关于sys运用:进度条

12345678910

def view_bar(num, total):    rate = num / total    rate_num = int(rate * 100)    r1 = '\r%s>%d%%' % ("="*num, rate_num,)  # 加 r 的话让每次输出回到初始最前面位置    sys.stdout.write(r1)  # 和print的区别就是不加换行符    sys.stdout.flush()  # 清空屏幕输出for i in range(0, 101):    time.sleep(0.1)    view_bar(i, 100)

5)os

系统级别的操作

os.getcwd()                 获取当前工作目录,即当前python脚本工作的目录路径os.chdir("dirname")         改变当前脚本工作目录;相当于shell下cdos.curdir                   返回当前目录: ('.')os.pardir                   获取当前目录的父目录字符串名:('..')os.makedirs('dir1/dir2')    可生成多层递归目录os.removedirs('dirname1')   若目录为空,则删除,并递归到上一级目录,如若也为空,则删除,依此类推os.mkdir('dirname')         生成单级目录;相当于shell中mkdir dirnameos.rmdir('dirname')         删除单级空目录,若目录不为空则无法删除,报错;相当于shell中rmdir dirnameos.listdir('dirname')       列出指定目录下的所有文件和子目录,包括隐藏文件,并以列表方式打印os.remove()                 删除一个文件os.rename("oldname","new")  重命名文件/目录os.stat('path/filename')    获取文件/目录信息os.sep                      操作系统特定的路径分隔符,win下为"\\",Linux下为"/"os.linesep                  当前平台使用的行终止符,win下为"\t\n",Linux下为"\n"os.pathsep                  用于分割文件路径的字符串os.name                     字符串指示当前使用平台。win->'nt'; Linux->'posix'os.system("bash command")   运行shell命令,直接显示os.environ                  获取系统环境变量os.path.abspath(path)       返回path规范化的绝对路径os.path.split(path)         将path分割成目录和文件名二元组返回os.path.dirname(path)       返回path的目录。其实就是os.path.split(path)的第一个元素os.path.basename(path)      返回path最后的文件名。如何path以/或\结尾,那么就会返回空值。即os.path.split(path)的第二个元素os.path.exists(path)        如果path存在,返回True;如果path不存在,返回Falseos.path.isabs(path)         如果path是绝对路径,返回Trueos.path.isfile(path)        如果path是一个存在的文件,返回True。否则返回Falseos.path.isdir(path)         如果path是一个存在的目录,则返回True。否则返回Falseos.path.join(path1[, path2[, ...]])  将多个路径组合后返回,第一个绝对路径之前的参数将被忽略os.path.getatime(path)      返回path所指向的文件或者目录的最后存取时间os.path.getmtime(path)      返回path所指向的文件或者目录的最后修改时间

6)hashlib

12345678910111213

# import hashlib# obj = hashlib.md5(bytes('sdfsdfsadf', encoding='utf-8'))  # 加bytes任意字符防止被撞库破译# obj.update(bytes('123', encoding='utf-8'))# r = obj.hexdigest()# print(r)# python内置还有一个 hmac 模块,它内部对我们创建 key 和 内容 进行进一步的处理然后再加密# import hmac# h = hmac.new(bytes('898oaFs09f',encoding="utf-8"))# h.update(bytes('admin',encoding="utf-8"))# print(h.hexdigest())

7)re

.  匹配除换行符以外的任意字符\w 匹配字母或数字或下划线或汉字\s 匹配任意的空白符\d 匹配数字\b 匹配单词的开始或结束^  匹配字符串的开始$  匹配字符串的结束*  重复零次或更多次+  重复一次或更多次?  重复零次或一次{n}   重复n次{n,}  重复n次或更多次

{n,m} 重复n到m次

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152

# import re# match# print(re.match('com', 'comwww.runcombb').group())  # match 匹配起始位置# print(re.search('com', 'www.runcombb').group())  # search 匹配第一次位置# sub subn 匹配 替换# print(re.sub("g.t", "have", 'I get A, get B', 1))  # 1表示只替换1次# print(re.subn("g.t", "have", 'I get A, get B'))  # 提示替换了几次# split# print(re.split('\d+', 'one1two2three3four4'))  # 有空格# 输出# ['one', 'two', 'three', 'four', '']# compile 封装一个固定匹配规则供多次调用# s = "JGood is a boy,so cool..."# r = re.compile(r'\w*oo\w*')   # 查找所有包含oo的单词# print(r.findall(s))# 输出:# ['JGood', 'cool']# 反斜杠# 在Python中 要进行两次转义才能匹配一个带反斜杠的字符 所以需要4个 \\\\# print(re.search("\\\\com", "\comcn").group())# 单词# print(re.findall(r'I\b', 'I&am Ikobe')) # 有很多字符可以用来分隔单词 这里使用 分组# 去已经匹配到的数据中再提取数据# origin = 'has sdfsdfsdfwer432'# r = re.match("h\w+", origin)  # 输出:has () {}# r = re.match("h(\w+)", origin)  # 输出:has ('as',) {}# r = re.match("h(?P\w+)", origin)  # 输出:has ('as',) {'name': 'as'}# print(r.group())# print(r.groups())# print(r.groupdict())# findall 分组# origin = "hasaabc halaaabc"# r = re.findall("h(\w+)a(ab)c", origin)  # 首先整体匹配 再将分组放入结果# print(r)# 输出:# [('as', 'ab'), ('ala', 'ab')]# spilt 分组# origin = "hello alex abc alex age"# r = re.split("a(le)x", origin, 1)  # 忽略了alex 直接匹配le# print(r)# 输出:# ['hello ', 'le', ' abc alex age']

常用正则表达式

12345678

# IP:# ^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$# 手机号:# ^1[3|4|5|8][0-9]\d{8}$# 邮箱:# [a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+

8)configparser

用于处理特定格式的文件 实质上是通过open来操作文件

源文件特定格式

12345678

[section1]k1 = 123k2 = v2[section2]k1 = 456k2 = v2k3 = v3

常见操作

123456789101112131415161718192021222324252627282930313233343536373839

import configparser# 1、读取文件 读取节点config = configparser.ConfigParser()config.read('conf_file', encoding='utf-8')ret = config.sections()  # 获取所有节点 返回一个列表ret1 = config.items('section1')  # 读取节点下的键值对ret2 = config.options('section1')  # 读取某个节点下的键print(ret)print(ret1)print(ret2)# 2、读取节点键值v = config.get('section1', 'k1')  # 获取指定key下的值 默认 str 类型# v = config.getint('section1', 'k1')# v = config.getfloat('section1', 'k1')# v = config.getboolean('section1', 'k1')print(v, type(v))# 3、检查 添加 删除节点has_sec = config.has_section('section1')print(has_sec)# config.add_section('section5')# config.write(open('conf_file', 'w'))# config.remove_section('section3')# config.write(open('conf_file', 'w'))# 4、检查 删除 设置 指定组内的键值对has_opt = config.has_option('section1', 'k1')print(has_opt)# config.remove_option('section2', 'k3')# config.write(open('conf_file', 'w'))config.set('section5', 'k1', '123')config.write(open('conf_file', 'w'))

9)xml

xml是实现不同语言和程序之间进行数据交换的协议

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889

from xml.etree import ElementTree as ET# xml有两个常见格式# 1)直接读取字符串格式的xmlstr_xml = open('xo.xml', 'r').read()root = ET.XML(str_xml)  # 这里没有建立 xml tree 所以不能直接将内存中的xml写回文件# 2)读取xml格式文件# tree = ET.parse('xo.xml')  # 首先建立了一个 xml tree 对象# root = tree.getroot()# print(root)  # 获取根节点# print(root.tag)  # 取根节点名# print(root.attrib)  # 获取节点属性# 3) 遍历多层xmlfor child in root:    print(child.tag, child.attrib)    for child_second in child:        print(child_second.tag, child_second.text)  # child_second.text 节点内容# 4) 遍历指定的节点for node in root.iter('year'):    print(node.tag, node.text)# 5) 修改节点内容for node in root.iter('year'):    new_year = int(node.text) + 1    node.text = str(new_year)    node.set('name', 'london')    node.set('age', '18')    del node.attrib['age']tree = ET.ElementTree(root)tree.write('new_xo.xml', encoding='utf-8')# 6、删除节点str_xml = open('xo.xml', 'r').read()root = ET.XML(str_xml)for country in root.findall('country'):    rank = int(country.find('rank').text)    if rank > 50:        root.remove(country)tree = ET.ElementTree(root)tree.write('new_xoo.xml', encoding='utf-8')# 7、创建 xml 文档from xml.dom import minidomdef prettify(elem):    """将节点转换成字符串,并添加缩进。    """    rough_string = ET.tostring(elem, 'utf-8')    reparsed = minidom.parseString(rough_string)    return reparsed.toprettyxml(indent="\t")# 创建根节点root = ET.Element("famliy")# 创建大儿子# son1 = ET.Element('son', {'name': '儿1'})son1 = root.makeelement('son', {'name': '儿1'})# 创建小儿子# son2 = ET.Element('son', {"name": '儿2'})son2 = root.makeelement('son', {"name": '儿2'})# 在大儿子中创建两个孙子# grandson1 = ET.Element('grandson', {'name': '儿11'})grandson1 = son1.makeelement('grandson', {'name': '儿11'})# grandson2 = ET.Element('grandson', {'name': '儿12'})grandson2 = son1.makeelement('grandson', {'name': '儿12'})son1.append(grandson1)son1.append(grandson2)# 把儿子添加到根节点中root.append(son1)root.append(son1)raw_str = prettify(root)  # 自动添加缩进f = open("xxxoo.xml", 'w', encoding='utf-8')f.write(raw_str)f.close()

10)shutil

用来处理 文件 文件夹 压缩包 的模块

123456789101112131415161718192021222324252627282930

import shutil# 拷贝文件内容shutil.copyfileobj(open('old.xml', 'r'), open('new.xml', 'w'))# 拷贝文件shutil.copyfile('f1.log', 'f2.log')# 拷贝权限shutil.copymode('f1.log', 'f2.log')# 拷贝文件状态信息shutil.copystat('f1.log', 'f2.log')# 拷贝文件和权限shutil.copy('f1.log', 'f2.log')# 递归地拷贝文件夹# shutil.copytree('folder1', 'folder2',ignore=shutil.ignore_patterns('*.pyc', '*.txt'))# 递归地删除文件# shutil.rmtree('folder2')# 递归地移动重命名文件# shutil.move('folder2', 'folder3')# 打包文件ret = shutil.make_archive(r'C:\GitHub\Python\day7\shutil\www', 'gztar',root_dir=r'C:\GitHub\Python\day7\shutil\folder1')

zipfile tarfile

123456789101112131415161718192021222324252627282930

import zipfile# 压缩z = zipfile.ZipFile('z.zip', 'w')z.write('xo.xml')z.write('xxxoo.xml')z.close()# 解压z = zipfile.ZipFile('z.zip', 'r')for item in z.namelist():    print(item)# z.extractall()z.extract('xo.xml')import tarfile# 压缩tar = tarfile.open('z.tar', 'w')tar.add('xo.xml', arcname='bbs2.log')tar.add('xxxoo.xml', arcname='cmdb.log')tar.close()# 解压tar = tarfile.open('z.tar', 'r')# for item in tar.getmembers():#     print(item, type(item))obj = tar.getmember('cmdb.log')  # 和zipfile不同的是 再解压特定文件前要先获取文件特殊对象值tar.extract(obj)tar.close()

11)系统命令

和处理shell相关的命令

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748

import subprocess# 返回命令执行结果# result = subprocess.call('ls -l', shell=True)# result = subprocess.call(['ls', '-l'], shell=False)# print(result)# subprocess.check_call(["ls", "-l"])# subprocess.check_call("exit 1", shell=True)# 好像没Python废弃了subprocess.check_output(["echo", "Hello World!"], shell=False)subprocess.check_output("exit 1", shell=True)# 2、执行复杂的系统相关命令# 1)切换目录再执行命令obj = subprocess.Popen("mkdir t3", shell=True, cwd='/home/dev',)# 2)有多行且复杂的命令使用三个接口# obj = subprocess.Popen(["python"], stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)# obj.stdin.write("print(1)\n")  # 传命令接口# obj.stdin.write("print(2)")# obj.stdin.close()## cmd_out = obj.stdout.read()  # 读接口# obj.stdout.close()# cmd_error = obj.stderr.read()  # 读错误接口# obj.stderr.close()## print(cmd_out)# print(cmd_error)# 3)一次读输出# obj = subprocess.Popen(["python"], stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)# obj.stdin.write("print(1)\n")# obj.stdin.write("print(2)")## out_error_list = obj.communicate()# print(out_error_list)# 4)简单写法# obj = subprocess.Popen(["python"], stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)# out_error_list = obj.communicate('print("hello")')# print(out_error_list)

python有哪些模块安全方向_Python 常用模块相关推荐

  1. micropython常用模块有那个_Python常用模块,不明觉厉先马后看

    这是我在网上找的常用内置模块总结,不是大全.我想,大全对于现在的我也没有什么用处,徒增压力和烦恼. 虽然有很多不明觉厉的东西,不过还是先存起来,以备将来不时之需. 常用的libraries(modul ...

  2. python email模块写邮件_python常用模块email----创建简单的文本邮件并发送

    email模块可以方便的用来构造邮件,今天我们通过一个简单的例子来实现文本邮件的构造的发送. 先将要发送的内容写在文件里面: cat /tmp/email_test.txt hello there! ...

  3. python os.path.splitext()的用法_Python常用模块之os.path

    os.path.abspath(path) 输入相对路径,返回绝对路径 Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1 ...

  4. python shelve模块_python常用模块之shelve模块

    python常用模块之shelve模块 shelve模块是一个简单的k,v将内存中的数据通过文件持久化的模块,可以持久化任何pickle可支持的python数据类型 我们在上面讲json.pickle ...

  5. python中threading模块详解及常用方法_Python常用模块功能简介(二)threading

    threading模块基本用法 threading.Thread.join函数解释 threading.Thread.join(timeout=None)调用该函数的线程会阻塞调用该线程的主线程和其它 ...

  6. python pp模块_python常用模块

    1.re模块 re模块用于对python的正则表达式的操作 1.1 什么是正则 正则就是用一些具有特殊含义的符号组合到一起(称为正则表达式)来描述字符或者字符串的方法.或者说:正则就是用来描述一类事物 ...

  7. python最常用的编程方式是什么_python常用模块和对象编程

    1.摘要 常用模块 对象编程 领域模型 2.常用模块 2.1shutil模块 2.1.1 shutil.copyfileobj(fsrc, fdst[, length]) 1 f = open(&qu ...

  8. python模块总结_Python常用模块资料总结和归纳

    Python模块是什么? 一个完整大型的python程序是由模块和包的形式组织起来的,可见模块在python中的重要性.模块是一种组织型式,它许多有关联(关系)的代码组织放到单独的独立文件中.简单的说 ...

  9. python电话模块_Python常用模块

    1.os模块 os模块包装了不同操作系统的通用接口,使用户在不同操作系统下,可以使用相同的函数接口,返回相同结构的结果. os.name:返回当前操作系统名称('posix', 'nt', 'os2' ...

最新文章

  1. head/tail实现
  2. 汉字转换成html,汉字与16进制、汉字与Html转义符的转换
  3. 7 种常用的排序算法直观感受
  4. 【SmartJob】【隔离】每天定时掉线问题解决:隔离定期重启脚本更新
  5. css3:绘制android3蜂巢Honeycomb
  6. php中 param,php中bind_param()函数用法分析
  7. android四周阴影效果_帮助独立开发者轻松创建令人惊叹的产品视觉效果
  8. 极路由 1S 使用经验
  9. SQL Server: create table sql script
  10. python中unexpectedtoken怎么解决_linux后台执行./run.py提示python syntax error near unexpected token `('...
  11. Spring Boot插件spring tool suite安装及使用
  12. java 打印制表符_开发简单的Java应用
  13. 分享淘宝利器飞天侠4.1至尊商业版 去除域名限制 绕过淘宝API直接采集
  14. 触摸式计算机屏幕,触控屏笔记本好不好 触摸屏笔记本优缺点分析【详细介绍】...
  15. 解决 Virtualbox 6.1.34 出现 End kernel panic - not syncing: attempted to kill the idle task
  16. 空间不足以提取VMware Tools解决方法
  17. Python自动化运维介绍
  18. Delphi Assigned 简单使用
  19. SPM软件的参考资料链接
  20. 在项目中用了Arrays.asList、ArrayList的subList,被老大公开批评

热门文章

  1. soul源码阅读 soul数据同步之nacos
  2. 屏蔽FF新推荐弹出框
  3. cygwin + swoole 安装
  4. 你上面写的代码用什么编程软件?
  5. 泳池马赛克让你徜徉在在海洋般的湛蓝与天际之间
  6. IPD(集成产品开发)
  7. Android-NBA比分文直播
  8. Android的各版本间的区别总结
  9. SQL中的连接(左、右、内连接)
  10. 如何更改windows2003最大连接数