From c569ae1af8afc3146b564e6aaa51888c64fbb671 Mon Sep 17 00:00:00 2001 From: JesterHey <144512889+JesterHey@users.noreply.github.com> Date: Mon, 4 Dec 2023 22:22:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=91=E5=AD=98=E5=82=A8=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloud.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cloud.py b/cloud.py index 4b680ed..500bf01 100644 --- a/cloud.py +++ b/cloud.py @@ -11,7 +11,7 @@ json_name = get_json(os.getcwd())[0] access_key_id = 'LTAI5t927vdUFZa9NRnWfrL3' access_key_secret = 'FbXoJUqe545eZhWFvADvGcFwatsGAx' bucket_name = 'tasks-jsons' -endpoint = '' +endpoint = 'oss-cn-shenzhen.aliyuncs.com' # 创建Bucket对象,所有Object相关的接口都可以通过Bucket对象来进行 bucket = oss2.Bucket(oss2.Auth(access_key_id, access_key_secret), endpoint, bucket_name) # 判断文件是否存在 @@ -19,10 +19,9 @@ exist = bucket.object_exists(json_name) # 如果文件存在,则下载到本地并覆盖本地文件 if exist: bucket.get_object_to_file(json_name, json_name) - print('已从云服务器下载文件') else: #否则调用OpenAI API获得答案,并上传到云服务器 new_data = get_answer.new_data - #将new_data变为json格式并上传到云端 + #将new_data变为json格式写入本地并上传到云端 with open(json_name, 'w', encoding='utf-8') as f: json.dump(new_data, f, ensure_ascii=False, indent=4) - bucket.put_object_to_file(json_name,json_name) + bucket.put_object_to_file(json_name,json_name) \ No newline at end of file