[英]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.