简体   繁体   English

尝试通过Shopify API提取订单数据时发生Python抛出错误

[英]Python throwing error when trying to pull order data via Shopify API

I am trying to play with this simple python script to pull order data from my shopify admin, but keep getting this error message (seems to be coming from line 6 as per terminal and sublime text) TypeError: not all arguments converted during string formatting: 我正在尝试使用这个简单的python脚本从shopify管理员中提取订单数据,但始终收到此错误消息(似乎是从第6行按终端和崇高文本显示的) TypeError:并非在格式化字符串时转换了所有参数:
Here is the script, 这是脚本,

import shopify

API_KEY = 'xxxxxxxxxxxxxxx'
PASSWORD = 'xxxxxxxxxxx'
SHOP_NAME = 'Shop name goes here'
shop_url = "https://xxxxxxxxxxxxx@xxxxxxxxxx.myshopify.com/admin" % (API_KEY, PASSWORD, SHOP_NAME)
shopify.ShopifyResource.set_site(shop_url)
shop = shopify.Shop.current()

order = shopify.Order()
num = order.count()
print num
success = order.find()
print success
der.save()
print success

I am at a loss for what I am doing wrong and have tried changing line 6 every which way as this is apparently where the error is coming from (from what terminal/sublime text tells me. Any input is appreciated, I am a complete newbie to Python. 我对自己做错的事情很茫然,尝试过每一种方式更改第6行,因为这显然是错误的出处(来自终端/崇高文本告诉我。任何输入,我是一个完整的新手,到Python。

Thanks! 谢谢!

shop_url = "https://xxxxxxxxxxxxx@xxxxxxxxxx.myshopify.com/admin" % (API_KEY, PASSWORD, SHOP_NAME)

replace above line with 用上面的行替换

shop_url = "https://xxxxxxxxxxxxx@xxxxxxxxxx.myshopify.com/admin/%s%s%s" % (API_KEY, PASSWORD, SHOP_NAME)

The correct way to use traditional string formatting using the '%' operator is to use a printf-style format string (Python documentation for this here ): 使用'%'运算符使用传统字符串格式的正确方法是使用printf样式的格式字符串(有关Python文档,请参见此处 ):

"'%s' is longer than '%s'" % (name1, name2) “'%s'长于'%s'”%(name1,name2)

However, the '%' operator will probably be deprecated in the future. 但是,将来可能不推荐使用'%'运算符。 The new PEP 3101 way of doing things is like this. 新的PEP 3101做事方式就是这样。

"'{0}' is longer than '{1}'".format(name1, name2) “'{0}'长于'{1}'”。format(name1,name2)

Line shop_url = "... 行shop_url =“ ...

Should in this format 应该采用这种格式

shop_url = " https://%s:%s@SHOP_NAME " % (API_KEY, PASSWORD) shop_url =“ https://%s:%s @ SHOP_NAME ”%(API_KEY,PASSWORD)

You are passing the shop_VAR and API,pass to the s% key to make the URL 您正在传递shop_VAR和API,并传递到s%键以创建URL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试使用 Python 通过 API 访问数据时出错 - Error when trying to access data via API using Python 尝试使用 shopifyapi 访问 shopify 数据并引发错误 - Trying to access the shopify data using shopifyapi and is throwing an error 尝试在 Rest Api 上拉取数据时出现 403 错误 - getting 403 error while trying run GET function on Rest Api to pull data in python 尝试从api中提取时,Python错误“列表索引必须是整数,而不是str” - Python error 'list indices must be integers, not str' when trying to pull from api 尝试在字段为空时提取详细信息时发生JIRA API错误 - JIRA API error when trying to pull details when field is empty 尝试使用API​​将网址中的数据提取到python时遇到问题 - Having trouble trying to pull data from a url into python using an API 尝试提取特定 API 响应数据时出现 KeyError - KeyError when trying to pull specific API Response Data 如何使用Shopify python API适配器提取资产? - How can I use the Shopify python api adapter to pull assets? Paramiko:尝试在远程服务器上执行 python 时抛出错误 - Paramiko : Throwing error when trying to execute python on remote server 尝试访问SharePoint列表时Python抛出401错误 - Python throwing 401 error when trying to access SharePoint lists
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM