1、打开pycharm工具,在项目中已新建的python文件中,导入os模块
2、定义函数judge_file,传入文件路径参数fname,并定义一个列表
3、再在judge_file函数下定义check_file函数,传入参数name
4、使用变量cname接收参数name,然后调用os.path中的isfile进行判断
5、对m[0]进行自增加一,然后使用os.path.isfile判断文件,调用check_file
6、最后依次返回cname,judge_file函数返回check_file函数
7、使用with...open方法打开tree.txt并写入数据,保存代码并运行文件,查看结果