I had a leetcode warehouse on GitHub a long time ago, but I didn't do much maintenance. Recently found himself brushed a lot of LC topic, want to move to this warehouse.
The most important thing to play GitHub is, of course, to write the Readme, MD's force lattice decided the project is not good. But let me write a link to a handwritten project it is impossible, this life is impossible handwriting, only the script automatically generated to meet the force of the appearance.
import osimport os.path# 根目录rootdir="E:/gitTest/LeetCode/"list=[]result=[]# 定义链接前缀prefix="https://github.com/rever4433/LeetCode/tree/master/"# 链接中的空格space="%20"for parent,dirnames,filenames in os.walk(rootdir): for dirname in dirnames: # 忽略的文件名 if dirname == ".git": continue # 文件夹名放入list if os.path.isdir(dirname): list.append(dirname) for i in list: linkSuffix=i.replace(" ",space) # 生成MD链接,格式:### 1.[Invert Tree]() i="### "+str(list.index(i)+1)+".["+i+"]("+prefix+linkSuffix+")" result.append(i)with open(‘test.md‘,‘w‘) as fw: fw.write(‘%s‘%‘\n‘.join(result))
Gadget: Automatically generate MD-style links using python