python-3.x - boto3 mturk:笑脸导致调用CreateHITWithHITType操作时发生错误(ParameterValidationError)
问题描述
使用 Python 3.7 和 boto3 在 MTurk 上创建 HIT,boto3 库崩溃并出现以下错误。我做了一些测试并得出结论,错误是由HITLayoutParameters
字段中的“”字符引起的(见下文)。
如何在仍以原始形式上传文本的同时避免此问题?
hit_layout_id = 'XXXXM4PUG5TWD3TK4NDUWHRJUUXXXX'
hit_layout_params = [{'Name': 'text', 'Value': 'Listening and learning, but standing strong pic.twitter.com/7TSroSf8h1 — Ilhan Omar (@IlhanMN) February 11, 2019\n<u><b>Omar</b></u> did not apologize, however, for another anti-Semitic comment she made in February, accusing pro-Israel Americans of having an “allegiance to a foreign country.”'}, {'Name': 'target', 'Value': 'Omar'}]
hit_type_id = 'XXXX7R2NRGZ96BC693FAIJ5481XXXX'
lifetime_in_seconds = 259200
num_max_assignments = 5
# boto3 client initialization
client = ...
# upload the hit
client.create_hit_with_hit_type(
HITTypeId=hit_type_id,
MaxAssignments=num_max_assignments,
LifetimeInSeconds=lifetime_in_seconds,
RequesterAnnotation=requester_annotation,
HITLayoutId=hit_layout_id,
HITLayoutParameters=hit_layout_params,
)
解决方案
那是一个编码问题。可以在您的应用程序中将您的文本编码为支持的编码并在您要使用它时对其进行解码?
推荐阅读
- amazon-web-services - 为在 AWS Route 53 上注册的 Netlify 子域配置 HTTPS
- python - 在基于 celery 的 Web 应用程序中运行使用 concurrent.futures 的 python 程序
- django - MAC - 如何查找和删除 postgres 服务器?
- c++11 - 错误:无效使用非静态成员函数
- python - 尝试在分配局部变量之前打印它的值
- javascript - javascript在本地主机上工作正常,但在实时服务器上却不行
- angular5 - 如何禁用 mat-list-item 的点击事件启用仅 maticon 的点击
- racket - 语法分析中的非语法语法
- business-intelligence - 需要有关处理 informatica 错误“值大于指定精度允许此列”的策略的建议,因为它会导致重复失败
- python - smtp2go 用户名的账户不允许发送