python为Github仓库生成目录

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Tony5t4rk/article/details/81983256

文章地址:http://henuly.top/?p=803

Github: Tony5t4rk/MyACM

# -*- coding:utf-8 -*-

import os

README = open('README.md', 'w')

def AC_Code():
    README.write('%s\n' % '## AC Code:')
    OJPos = os.getcwd() + '/AC代码'
    OJs = os.listdir(OJPos)
    for OJ in OJs:
        README.write('%s\n' % str('### ' + OJ + ':'))
        ProblemPos = OJPos + '/' + OJ
        Problems = os.listdir(ProblemPos)
        for Problem in Problems:
            README.write('%s\n' % str('* [' + Problem[:-4] + '](https://github.com/Tony5t4rk/MyACM/tree/master/AC%E4%BB%A3%E7%A0%81/' + OJ + '/' + Problem + ')'))

def My_Template():
    README.write('%s\n' % '## My Template:')
    TemplatePos = os.getcwd() + '/我的模板'
    Templates = os.listdir(TemplatePos)
    for Template in Templates:
        README.write('%s\n' % str('* [' + Template[:-4] + '](https://github.com/Tony5t4rk/MyACM/tree/master/%E6%88%91%E7%9A%84%E6%A8%A1%E6%9D%BF/' + Template + ')'))

def main():
    README.write('%s\n' % '# MY ACM')
    AC_Code()
    My_Template()
    README.write('%s\n' % '![](http://p980l5uv6.bkt.clouddn.com/18s.jpg)')
    README.close()

if __name__ == '__main__':
    main()

猜你喜欢

转载自blog.csdn.net/Tony5t4rk/article/details/81983256