在IDLE中运行代码时,它什么也不显示。
from ibm_botocore.client import Config
import ibm_boto3
def upload_file(credentials,local_file_name,key):
cos = ibm_boto3.client(service_name='s3',
ibm_api_key_id=credentials['got from service credential desciption'],
ibm_service_instance_id=credentials['got from service credential description'],
ibm_auth_endpoint=credentials['s3.eu-gb.cloud-object-storage.appdomain.cloud'],//as my region is London
config=Config(signature_version='oauth'),
endpoint_url=credentials['https://control.cloud-object-storage.cloud.ibm.com/v2/endpoints'])
try:
res=cos.upload_file(Filename='D:\ibm-cloud\get-started-python\abc.txt', Bucket=credentials['cloud-college-bucket0'],Key=key)
except Exception as e:
print(Exception, e)
else:
print('File Uploaded')
答案 0 :(得分:0)
您的代码定义了一个函数,但未调用它。因此,预期结果或结果根本没有任何输出。一切都很好。
您的下一步应该是拥有一个主函数或在您的已定义函数upload_file
的上层调用代码。