小编zhw*_*x22的帖子

如何使用重复键将元组列表转换为字典?

我该如何转换元组列表,如:

query_res = [('a3','b6','c1'),
             ('a3','b6','c2'),
             ('a3','b6','c3'),
             ('a3','b7','c4'),
             ('a4','b8','c5'),
             ('a4','b8','c6')]
Run Code Online (Sandbox Code Playgroud)

像这样的字典:

result = {
    'a3': {
        'b6': ['c1', 'c2', 'c3'],
        'b7': ['c4']
    },
    'a4': {
        'b8': ['c5', 'c6']
    }
}
Run Code Online (Sandbox Code Playgroud)

我尝试了defaultdict,错误只能获取内部dict,如何映射ares此处?:

res = defaultdict(list)
for a, b, c in query_res:
    res[b].append(c)
Run Code Online (Sandbox Code Playgroud)

python dictionary

4
推荐指数
1
解决办法
80
查看次数

unable to access kubernetes dashboard via token

  1. I have setup a kubernetes using kubeadm v1.8.5
  2. Setup a dashboard using:
wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.8.0/src/deploy/recommended/kubernetes-dashboard.yaml`

kubectl create -f kubernetes-dashboard.yaml

kubectl create -f kubernetes-dashboard-admin.rbac.yaml
Run Code Online (Sandbox Code Playgroud)
  1. Then setup kubectl proxy, using http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/ as recommended.

  2. When I am trying to login using kubernetes-dashboard-admin token. Token was received by using the command:

    kubectl -n kube-system get secret | grep -i dashboard-admin | awk '{print $1}' | xargs -I {} 
    kubectl -n kube-system describe secret {}
Run Code Online (Sandbox Code Playgroud)

Here comes my problem: I CANT access the dashboard via token, …

dashboard kubernetes kubeadm

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

标签 统计

dashboard ×1

dictionary ×1

kubeadm ×1

kubernetes ×1

python ×1