在何处声明图形中的变量;python

在何处声明图形中的变量;python,python,graphql,Python,Graphql,这里有一个Graphql查询,我想在python脚本中实现它 #!/usr/bin/python # -*- coding: utf-8 -*- ##TOKEN Info import requests from web3 import Web3 bsc = "https://bsc-dataseed.binance.org/" web3 = Web3(Web3.HTTPProvider(bsc)) print(web3.isConnected()) #addre

这里有一个Graphql查询,我想在python脚本中实现它

#!/usr/bin/python
# -*- coding: utf-8 -*-

##TOKEN Info
import requests
from web3 import Web3


bsc = "https://bsc-dataseed.binance.org/"
web3 = Web3(Web3.HTTPProvider(bsc))

print(web3.isConnected())


#address = web3.toChecksumAddress(input('Enter BNB address: '))
#addressA = str(address)


def run_query(query):  # A simple function to use requests.post to make the API call.
    headers = {'X-API-KEY': 'AAAAAPIIIIKKEYYYY'}
    request = requests.post('https://graphql.bitquery.io/',
                            json={'query': query}, headers=headers)
    if request.status_code == 200:
        return request.json()
    else:
        raise Exception('Query failed and return code is {}.      {}'.format(request.status_code,
                        query))


# The GraphQL query



#Get TokenInfo'
query = """


query ($network: EthereumNetwork!, $tokens: [String!], $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    transfers(
      currency: {in: $tokens}
      amount: {gt: 0}
      date: {since: $from, till: $till}
    ) {
      currency {
        symbol
        name
        address
      }
      median: amount(calculate: median)
      average: amount(calculate: average)
      amount
      count
      days: count(uniq: dates)
      sender_count: count(uniq: senders)
      receiver_count: count(uniq: receivers)
      min_date: minimum(of: time)
      max_date: maximum(of: time)
    }
  }
}


"""
result = run_query(query)  # Execute the query
#print('Result - {}'.format(result))



print(result)
变量的定义如下:

{
  "network": "bsc",
  "from": "2021-03-30",
  "tokens": [
    "0x6615a63c260be84974166a5eddff223ce292cf3d"
  ]
}
我必须在脚本中的何处放置这些变量,以便在运行查询时使用它。 我试图将它们硬编码到查询中,但这不起作用

我还尝试将其添加到查询中,但这也不起作用