使用以下代码:
import os
from azure.identity import (
ClientSecretCredential
)
# Import the client object from the Azure library
from azure.storage.blob import BlobClient
t_id = "<tenant_id>"
c_id = "<client_id>"
s_acct = "<storage_account_name>"
s_acct_url = "%s.blob.core.windows.net" % s_acct
sek = "<client_sekret>"
print("+ Setup credentials.")
credential = ClientSecretCredential(t_id, c_id, sek)
print("+ Setup Blob Client")
bobc = BlobClient(s_acct_url, <container_name>, <blob_name>,
credential=credential)
print("+ Setup streamer")
ssd = bobc.download_blob()
print("+ Get properties")
print(ssd.get_blob_properties())
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
$ python azdown.py
+ Setting up stream
+
+ Download stream:
+ …Run Code Online (Sandbox Code Playgroud) 通过此处找到的 Rabbit MQ Pika HelloWorld 教程:https : //www.rabbitmq.com/tutorials/tutorial-one-python.html
问题是,每当我运行接收脚本时,我都会收到此错误:
Traceback (most recent call last):
File "receive.py", line 5, in <module>
pika.ConnectionParameters(host='localhost'))
File "C:\Users\Colin Warn\PycharmProjects\untitled2\venv\lib\site-packages\pika\adapters\blocking_connection.py", line 360, in __init__
self._impl = self._create_connection(parameters, _impl_class)
File "C:\Users\Colin Warn\PycharmProjects\untitled2\venv\lib\site-packages\pika\adapters\blocking_connection.py", line 451, in _create_connection
raise self._reap_last_connection_workflow_error(error)
pika.exceptions.AMQPConnectionError
Run Code Online (Sandbox Code Playgroud)
这是我试图运行的代码:
#!/usr/bin/env python
import pika
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
def callback(ch, method, properties, body):
print(" [x] Received %r" % body)
channel.basic_consume(
queue='hello', on_message_callback=callback, auto_ack=True)
print(' [*] Waiting for messages. To exit press CTRL+C') …Run Code Online (Sandbox Code Playgroud)