Overwriting Google Drive API v3 Argparse in Python

后端 未结 2 2000
闹比i
闹比i 2020-12-19 20:22

I\'m trying to use the Google Drive API (v3) with Python to obtain and upload files to my Google Drive account.

I used this guide to setup my authentication: https:

2条回答
  •  孤城傲影
    2020-12-19 21:16

    I think there have been other questions about argparse and the google api, but I haven't used the latter.

    Parsers are independent and can't be over written. But they all (as a default anyways) use sys.argv[1:]. So if your code runs before the other one, you can edit sys.argv to remove the extra strings. Using parse_known_args is a handy way of separating your arguments from ones the other parser(s) should use.

    Often the parser is invoked from a if __name__ block. That way imported modules don't do parsing, only ones used as scripts. But I don't if the google api makes this distinction.

提交回复
热议问题