(index_info)
生成 readme.md 索引文件，包含所有文件目录
生成 readme.md 索引文件，包含所有文件目录
生成 readme . md 索引文件，包含所有文件目录
def render_index_page(index_info):
    '''
    生成 readme.md 索引文件，包含所有文件目录
    '''
    # 重新排序
    index_info = sorted(index_info.items(), key=lambda item:item[0], reverse=False)

    # 写入文件
    with open(index_path, 'w+', encoding="utf-8") as file:
        file.write(readme_header)
        for chp, info in index_info:
            chp_name = info["name"]
            file.write("## " + chp_name + "\n")
            for line in info["contents"]:
                file.write(line)
            file.write("\n")
        file.write(readme_tooter)
def render_index_page ( index_info ) : # 重新排序 index_info = sorted ( index_info . items ( ) , key = lambda item : item [ 0 ] , reverse = False ) # 写入文件 with open ( index_path , 'w+' , encoding = "utf-8" ) as file : file . write ( readme_header ) for chp , info in index_info : chp_name = info [ "name" ] file . write ( "## " + chp_name + "\n" ) for line in info [ "contents" ] : file . write ( line ) file . write ( "\n" ) file . write ( readme_tooter )