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:
Here is the script,
import shopify
API_KEY = 'xxxxxxxxxxxxxxx'
PASSWORD = 'xxxxxxxxxxx'
SHOP_NAME = 'Shop name goes here'
shop_url = "https://[email protected]/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.
Thanks!
2
Answers
replace above line with
The correct way to use traditional string formatting using the ‘%’ operator is to use a printf-style format string (Python documentation for this here):
However, the ‘%’ operator will probably be deprecated in the future. The new PEP 3101 way of doing things is like this.
Line shop_url = “…
Should in this format
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