博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python总结--目录(转)
阅读量:5319 次
发布时间:2019-06-14

本文共 2581 字,大约阅读时间需要 8 分钟。

python模块
 
 
  
  
  
 
 
 
 
 
 
 

一 python文章索引

 

To tal number is :102
python基础:
python类库:
python实例:
python技巧:
python其他:
 

二 python31代码用来自动生成本索引 (需要保存为utf-8格式)

1 #-*- coding: utf-8 -*- 2  3 import urllib.request 4 import re 5  6 pythontagurl = "http://www.cnblogs.com/itech/category/170012.html" 7 pythonarticleurlregrex = "(
([Pp]ython.*?))" 8 9 # get the page content string which contains all python article links10 pythontagpage = urllib.request.urlopen(pythontagurl)11 pythontagstr = ""12 for line in pythontagpage.readlines():13 try:14 newline = line.decode('utf-8', 'strict')15 #print(newline)16 except:17 continue18 pythontagstr += newline19 pythontagpage.close()20 21 # get all link and sort 22 pythonlinkandtiles = re.findall(pythonarticleurlregrex, pythontagstr)23 d = dict()24 for link, title in pythonlinkandtiles:25 d[title] = link26 pythontitles = list(d.keys())27 bstr1 = "python基础"28 bstr2 = "python语法"29 estr = "python实例"30 lstr = "python类库"31 tstr = "python技巧"32 ostr = "python其他"33 basic = []34 examples = []35 libs = []36 tips = []37 others = []38 for k in pythontitles:39 if k.startswith(bstr1) or k.startswith(bstr2):40 basic.append(k)41 elif k.startswith(estr) :42 examples.append(k)43 elif k.startswith(lstr) :44 libs.append(k)45 elif k.startswith(tstr):46 tips.append(k)47 else:48 others.append(k)49 basic.sort()50 libs.sort()51 examples.sort()52 tips.sort()53 others.sort()54 55 pythonarticles = []56 fonts = "
"57 fonte = ":"58 pythonarticles.append( fonts + bstr1 + fonte )59 for py in basic: pythonarticles.append(d[py]) 60 pythonarticles.append(fonts + lstr + fonte )61 for py in libs: pythonarticles.append(d[py])62 pythonarticles.append(fonts + estr + fonte ) 63 for py in examples: pythonarticles.append(d[py]) 64 pythonarticles.append(fonts + tstr + fonte )65 for py in tips: pythonarticles.append(d[py])66 pythonarticles.append(fonts + ostr + fonte )67 for py in others: pythonarticles.append(d[py]) 68 69 # generate pythonindex.html70 pythonindex = open("pythonindex.html", "w",encoding='utf-8')71 pythonindex.write("")72 pythonindex.write("")73 pythonindex.write("
")74 pythonindex.write("
Python - iTech's Blog")75 pythonindex.write("")76 pythonindex.write("")77 pythonindex.write("Total number is :" + str(len(pythonarticles)) + "
")78 for pa in pythonarticles:79 pythonindex.write(pa)80 pythonindex.write("
")81 pythonindex.write("")82 pythonindex.write("")83 pythonindex.close()

 

作者:

出处:

 

 

转载于:https://www.cnblogs.com/WayneZeng/p/3224578.html

你可能感兴趣的文章
MyEclipse中将普通Java项目convert(转化)为Maven项目
查看>>
node js 安装.node-gyp/8.9.4 权限 无法访问
查看>>
windows基本命令
查看>>
VMware中CentOS设置静态IP
查看>>
[poj1006]Biorhythms
查看>>
Hyper-V虚拟机上安装一个图形界面的Linux系统
查看>>
Hover功能
查看>>
js千分位处理
查看>>
Mac---------三指拖移
查看>>
字符串类型的相互转换
查看>>
HTTP状态码
查看>>
iOS如何过滤掉文本中特殊字符
查看>>
基础学习:C#中float的取值范围和精度
查看>>
javaagent 简介
查看>>
python升级安装后的yum的修复
查看>>
Vim配置Node.js开发工具
查看>>
web前端面试题2017
查看>>
ELMAH——可插拔错误日志工具
查看>>
MySQL学习笔记(四)
查看>>
【Crash Course Psychology】2. Research & Experimentation笔记
查看>>