skip to Main Content

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


  1. shop_url = "https://[email protected]/admin" % (API_KEY, PASSWORD, SHOP_NAME)
    

    replace above line with

    shop_url = "https://[email protected]/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):

    “‘%s’ is longer than ‘%s'” % (name1, name2)

    However, the ‘%’ operator will probably be deprecated in the future. The new PEP 3101 way of doing things is like this.

    “‘{0}’ is longer than ‘{1}'”.format(name1, name2)

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search