1 #!/usr/bin/python
2 #-*- coding: utf-8 -*-
3 importos4
5 #pathMain = r"E:\manhua\mh"
6 pathMain =os.getcwd()7 defcreateIndex():8 for paths, folders, filenames inos.walk(pathMain):9 #print(folders)
10 for folder infolders:11 root =os.path.join(paths,folder)12 page =len(os.listdir(root))13 #print(page)
14 os.chdir(root)15 html = open("index.html","w",encoding="utf-8")16 text = '''
17 18 19
20 21 22 '''+folder+'''23 31 32 33'''+folder+'''
3448 html.write(text)49 html.close()50 defcreateMain():51 filenames =os.listdir(pathMain)52 os.chdir(pathMain)53 folders =[]54 for filename infilenames:55 ifos.path.isdir(filename):56 folders.append(filename)57
58 with open("booklist.js","w",encoding="utf-8") as f1:59 txt1 = ""
60 for folder infolders:61 txt1 += "'"+folder+"'" + ","
62 booklist = '''
63 var booklist = ['''+txt1[0:-1]+'''];64 '''
65 f1.write(booklist)66 with open("main.html","w",encoding="utf-8") as f:67 txt = '''
68 69 70
71 72 73 妖气漫画74 80 81 8297 '''
98 f.write(txt)99
100 createMain()101 createIndex()