2017-02-03 4 views
0
gist_ids = 'abc' 

    def main(): 
     gh = github3.login (
      token=os.environ.get('my_token'), 
      url=' ') 
     my_gist = gh.gist(gist_ids) 

     resp = github3.gists.history.GistHistory(json, session=None) 

     print json.dumps(resp) 
    if __name__ == '__main__': 
    main() 

私はリビジョンデータフォームgistを取得し、jsonの形式で保存しようとしています。 PythonのAPIにGithub要旨のリビジョンデータを取得する

新しい私に点灯してください人々

Error: 

Traceback (most recent call last): 
    File "push.py", line 51, in <module> 
    main() 
    File "push.py", line 26, in main 
    resp = github3.gists.history.GistHistory(json, session=None) 
NameError: global name 'json' is not defined 
+0

あなたはファイルの先頭に '輸入json'する必要があります。 – Amber

+0

@Amberは(最後の最新の呼び出し)JSON 'トレースバックをインポート:メイン RESP = github3で メイン() ファイル "push.py" で ファイル "push.py"、52行、27行を、 .gists.history.GistHistory(json、session = None) ファイル "/Library/Python/2.7/site-packages/github3/models.py"、47行目、__init__ self.etag = json.pop( 'ETag '、None) AttributeError:' module 'オブジェクトには属性' pop''がありません –

答えて

0

インストールしたgithub3.pyのバージョンによって次の2つのオプションがあります:あなたはアルファ版を使用している場合

  1. を1.0の場合、my_gistオブジェクトでcommits()メソッドを使用する必要があります。 (ドキュメンテーション:http://github3.readthedocs.io/en/develop/gists.html

  2. 0.9シリーズのバージョンを使用している場合は、同じオブジェクトに対してiter_commits()メソッドを使用する必要があります。 (ドキュメント:http://github3.readthedocs.io/en/stable/gists.html#github3.gists.gist.Gist.iter_commits

これらは、おおよそ次のように動作します:

# 1.0.0a4 
for gist_commit in my_gist.commits(): 
    # do stuff with previous version 
# 0.9.6 
for gist_commit in my_gist.iter_commits(): 
    # ... 

また

# 1.0.0a4 
my_gist_history = list(my_gist.commits()) 
# 0.9.6 
my_gist_history = list(my_gist.iter_commits()) 
関連する問題