为了提供一些上下文,我有一个转换器,它分两步请求 JSON 数据,第一步是请求完整数量的 Data_points,第二步是请求每个数据点的详细信息。为了跟踪进度,因为我期望从此时开始请求大量数据。这就是我使用 tqdm 的原因,它确实使我的程序执行速度减慢了至少 8 倍。
\nimport requests\nimport json\nimport os\nimport time\nfrom datetime import timedelta\nfrom datetime import datetime\nfrom datetime import date\nimport pandas as pd\nimport shutil\nimport zipfile\nimport smtplib, ssl\nfrom progress.bar import Bar\nfrom tqdm import tqdm\nfrom time import sleep\nRun Code Online (Sandbox Code Playgroud)\n这是代码:
\ndef fetch_data_points(url: str):\n limit_request = 100\n # Placeholder for limit: please do not remove = 1000000000 -JJ\n folder_path_reset("api_request_jsons","csv","Geographic_information")\n total_start_time = start_time_measure()\n start_time = start_time_measure(\n \'Starting Phase 1: First request from API: Data Points\')\n\n for i in tqdm(range(limit_request)):\n response …Run Code Online (Sandbox Code Playgroud)