【python】模块整理

---文件、系统---

import glob  # 给定路径下查找符合规则文件。三个匹配符:”*”, “?”, “[]”。”*”匹配0个或多个字符;”?”匹配单个字符;”[]”匹配指定范围内的字符,如:[0-9]匹配数字。

print glob.glob("../*/*.jpg")  # 返回数组

import os

import sys

import time

 

 

---字符串---

import string  # 字符串相关,譬如大小写改变,字符判断

from string import Formatter  # 字符串替换。通过position和keyword来指定替换对象

"my name is {0.name}, I am living at {area[0].city}".format(person, area_list)

from string import Template  # 字符串替换。默认通过$来指定替换对象

header = '''<title>$title</title>'''

header.substitute(title=the_title)

参考文档:

http://blog.csdn.net/xiaoxiaoniaoer1/article/details/8542834

http://www.cnblogs.com/rollenholt/archive/2011/11/25/2263722.html

http://www.cnblogs.com/youngershen/p/3972009.html

 

---Server---

BaseHTTPServer 

http://blog.csdn.net/linda1000/article/details/8087546

SimpleHTTPServer  # HTTP 服务

CGIHTTPServer  # CGI 服务

注意!有CGI脚本时,应该用CGIHTTPServer启服务,如果SimpleHTTPServer的话,会直接展示脚本内容

 

---网络请求---

import urllib

import urllib2

 

 

---进程、线程---

import threading

import multiprocessing 

 

 

---图片---

posted @ 2017-07-24 13:21  xidd  阅读(161)  评论(0编辑  收藏  举报