小编Han*_*ham的帖子

如何使用一个命令行运行 Python 包

我是 Python 的新手。而且我不知道如何只用一个命令行运行一个 python 包。我已经在 GG 上搜索过它,但我没有关键字。有我的文件夹:

??? config.json
??? my_source
    ???__init__.py
    ???filter.py
    ???get_new_users.py
Run Code Online (Sandbox Code Playgroud)

并且 config.json 包含 3 个参数并且可以由用户更改。所以,我想用这样的一个命令行运行这个 my_source 包:

my_source -c config.json

我可以以这种方式运行我的代码吗?如果它是可能的。谁能给我一个关键字或一种方法?如果您需要更多信息,请发表评论。谢谢你。

python python-3.x

4
推荐指数
1
解决办法
1万
查看次数

无法使用 Python 3 将 MessageAttributes 发送到 AWS SQS

我正在尝试使用 boto3 库写入 SQS 消息属性。

import boto3
sqs = boto3.client('sqs')

response = sqs.send_message(
    QueueUrl = 'https://queue.amazonaws.com/xxxxx/test',
    MessageBody='test01',
    MessageAttributes={
        'from': {
            'StringValue': '2019-12-11',
            'DataType': 'string'
        }
    }
)
Run Code Online (Sandbox Code Playgroud)

但我收到错误消息:

botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the SendMessage operation: The type of message (user) attribute 'from' is invalid. You must use only the following supported type prefixes: Binary, Number, String.
Run Code Online (Sandbox Code Playgroud)

我也尝试了几种方法,但也没有成功。谁能帮我解决这个错误吗?

如果还有其他方法可以做到这一点,我也将不胜感激?谢谢!

amazon-sqs python-3.x

4
推荐指数
1
解决办法
6311
查看次数

如何将 GG Bigquery 中存储的数据导出到 GZ 文件。

我使用此代码将数据导出到 csv 文件,它可以工作:

project_id = 'project_id'
client = bigquery.Client()
dataset_id = 'dataset_id'
bucket_name = 'bucket_name'
table_id = 'table_id'

destination_uri = 'gs://{}/{}'.format(bucket_name, 'file.csv')
dataset_ref = client.dataset(dataset_id, project=project_id)
table_ref = dataset_ref.table(table_id)

extract_job = client.extract_table(
    table_ref,
    destination_uri) 
extract_job.result() 
Run Code Online (Sandbox Code Playgroud)

但我更喜欢GZ文件,因为我的表高达700M。谁能帮我将数据导出到 GZ 文件中?

export python-3.x google-bigquery

3
推荐指数
1
解决办法
1088
查看次数

标签 统计

python-3.x ×3

amazon-sqs ×1

export ×1

google-bigquery ×1

python ×1