小编Deb*_*urr的帖子

NameError:名称“ argv”未定义

我正在尝试进行Google API调用,并且在此处找到的代码开头出现错误:

import os

import argparse
import sys

from apiclient import sample_tools
from oauth2client import client

# Declare command-line flags.
argparser = argparse.ArgumentParser(add_help=False)
argparser.add_argument(
    'profile_id', type=int,
    help='The ID of the profile to look up campaigns for')



  # Authenticate and construct service.
service, flags = sample_tools.init(
    argv[1:], 'dfareporting', 'v2.1', __doc__, os.path.abspath(os.path.dirname("__file__")), parents=[argparser],
    scope=['https://www.googleapis.com/auth/dfareporting',
           'https://www.googleapis.com/auth/dfatrafficking'])

if __name__ == '__main__':
  main(sys.argv)
Run Code Online (Sandbox Code Playgroud)

但是,sample_tools.init函数不会返回服务和标志对象。我认为我已经将其隔离到argv参数a

NameError: name 'argv' is not defined
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激!!!

python google-api argv python-3.4

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

argv ×1

google-api ×1

python ×1

python-3.4 ×1