我正在尝试从 gitlab 读取该文件。我为此在 gitlab 中创建了访问令牌。下载的模块 python-gitlab
我从 PyCharm 安装了模块 python-gitlab:文件 --> 设置 --> Python 解释器 --> python-gitlab
import gitlab
import json
from pprint import pprint
import requests
import urllib.request
# private token authentication
gl = gitlab.Gitlab('https://gitlab.com/..../CSV_HOMEWORK.csv', private_token='xxx')
gl.auth()
# list all projects
projects = gl.projects.list()
for project in projects:
# print(project) # prints all the meta data for the project
print("Project: ", project.name)
print("Gitlab URL: ", project.http_url_to_repo)
# print("Branches: ", project.repo_branches)
pprint(project.repository_tree(all=True))
f = urllib.request.urlopen(project.http_url_to_repo)
myfile = …Run Code Online (Sandbox Code Playgroud) 我有一本字典,可能只有这些键。但可以有 2 个键,例如'news'and'coupon'或 only 'coupon'。如何检查字典是否为空?(下面的词典是空的。)
{'news': [], 'ad': [], 'coupon': []}
{'news': [], 'coupon': []}
Run Code Online (Sandbox Code Playgroud)
我写了代码,但它应该只需要 3 个键:
if data["news"] == [] and data["ad"] == [] and data["coupon"] == []:
print('empty')
Run Code Online (Sandbox Code Playgroud)
怎样才能不只带3把钥匙?