• 十周年快乐,
    期待下一个十年。

  • 无法抓包,可以参考 https://www.jianshu.com/p/392362115090 让开发针对 debug 配置单独构建一个 apk

  • import requests
    
    
    def build_upload_files(file_name_list):
        # 优化1: 将公共的文件夹路径抽离
        root_folder_path = r'F:\code\pytest-auto-api2-master\requests_demo\demo'
    
        temp_upload_files = dict()
    
        # 优化2: 将重复冗余的代码用循环生成字典对象
        for index, file_name in enumerate(file_name_list, start=1):
            temp_upload_files.update({f'field{index}': ('file', open(root_folder_path + '\\' + file_name, 'rb'))})
    
        return temp_upload_files
    
    
    if __name__ == '__main__':
        # 优化3: 可以从配置文件中读取file_name_list
        file_names = ['Project.xls', 'Projects\\testdata.xls']
    
        upload_files = build_upload_files(file_names)
        requests.post(url='https://www.xx.com', files=upload_files)