递归删除文件夹
import os
# def delete_path2(path):
# #     if os.path.isfile(path):
# #         os.remove(path)
# #     elif os.path.isdir(path):
# #         # 遍历文件夹内容
# #         for filename in os.listdir(path):
# #             sub_path = os.path.join(path, filename)
# #             delete_path2(sub_path)
# #         # 删除文件夹
# #         os.rmdir(path)
# #     else:
# #         print("路径不存在!")
# #使用配置文件完成记录用户名与密码,登录前判断是否存在相应的配置信息 不存在则正常输入用户名密码,
存在则直接读取配置进行登录,首次登录成功后记录将用户密码写入配置文件
# #
# # delete_path2(r"")
#
# import configparser
# name=input('请输入用户名')
# passw=input('请输入密码')
# cfg=configparser.ConfigParser()
# cfg.read('xinxi.cfg')
# if not cfg.sections():
#     cfg.add_section('dengluxinxi')
#     cfg.set('dengluxinxi','username',name)
#     cfg.set('dengluxinxi', 'password', passw)
#     with open ('xinxi.cfg','wt',encoding='utf-8') as f:
#         cfg.write(f)
# else:
#     with open ('xinxi.cfg',encoding='utf-8') as f:
#         cfg.read(f)
#     nam=cfg.get('dengluxinxi','username')
#     mim=cfg.get('dengluxinxi','password')
#     if name==nam and mim==passw:
#         print('登陆成功')
实现一个上传文件功能,upload 参数为一个路径,首先判断路径是否存在,在判断是否是一个文件,
是文件则打印开始上传,是文件夹则现将文件夹压缩,在打印开始上传
#
# import os
# import configparser
# def xunzai(lujing):
#     cfg=configparser.ConfigParser()
#     cfg.read('download.cfg',encoding='utf-8')
#
#     if not cfg.sections():
#         cfg.add_section('download_path')
#         cfg.set('download_path','download_path',lujing)
#         # cfg.set('dengluxinxi', 'password', passw)
#         with open ('download.cfg','wt',encoding='utf-8') as f:
#             cfg.write(f)
#     else:
#         if os.path.exists(lujing):
#             print('正确')
#         else:
#             print('错误')
# xunzai(r'')
在配置文件中增加一个download_path路径,用于表示用户下载路径,运行程序时先检查,该路径是否存在,
不存在则直接创建,存在时,判断是否是一个正确的文件夹路径
# import os
# import shutil
# # list1=[]
# def panduan(lujing):
#  if os.path.exists(lujing):
#      if os.path.isfile(lujing):
#          print('lujing')
#          # shutil.copy('lujing','')
#      elif os.path.isdir(lujing):
#          # r=list.extend(list1,os.path.split('lujing'))
#          shutil.make_archive('test.zip','zip',lujing)
# panduan(r'')