我正在尝试将我的 docker 映像推送到 google 容器映像注册表,但收到一条错误消息,指出我没有执行此操作所需的权限。
我已经尝试过 gcloud auth configure-docker 但它对我不起作用。
我首先使用以下命令构建映像: docker build -t gcr.io/trynew/hello-world-image:v1 。
然后我试图附加一个标签并推送它: docker push gcr.io/trynew/hello-world-image:v1
这是我的输出:
The push refers to repository [gcr.io/trynew/hello-world-image]
e62774cdb1c2: Preparing
0f6265b750f3: Preparing
f82351274ce3: Preparing
31a16430afc8: Preparing
67298499a3ed: Preparing
62d5f39c8fe4: Waiting
9f8566ee5135: Waiting
unauthorized: You don't have the needed permissions to perform this
operation, and you may have invalid credentials.
To authenticate your request, follow the steps in:
https://cloud.google.com/container-registry/docs/advanced-authentication
Run Code Online (Sandbox Code Playgroud) 我正在尝试获取从 url 返回的数据。卷曲到 url 结果如下:
[{"name": "Hello World!"}]
以下是我的 App.js 中的代码
import React, { Component } from 'react';
import Contacts from './components/contacts';
class App extends Component {
render() {
return (
<Contacts contacts={this.state.contacts} />
)
}
state = {
contacts: []
};
componentDidMount() {
fetch('url')
.then(res => res.json())
.then((data) => {
this.setState({ contacts: data })
})
.catch(console.log)
}
}
export default App;
Run Code Online (Sandbox Code Playgroud)
我的 contact.js 包含以下内容:
// src/components/contacts.js
import React from 'react'
const Contacts = ({ contacts }) => {
return …Run Code Online (Sandbox Code Playgroud) 我正在使用 Python 的 SortedDict 容器来解决一个问题,并且想知道获取最高键的时间复杂度是多少:
from sortedcontainers import SortedDict
treeMap = SortedDict()
treeMap[1] = [4]
treeMap[1].append(6)
treeMap[3] = [9]
print(treeMap.keys()[-1]) # get the highest key in the sorted dictionary, should be 3
Run Code Online (Sandbox Code Playgroud)
我知道 SortedDict 中的大多数操作都是 O(log(n)) 但我对 treeMap.keys()[-1] 特别感到困惑。对于普通字典,d.keys()在python3中是O(1)..d.keys()[-1]也是O(1)吗?是 log(n) (在 Sorteddict 的情况下)还是 O(n) (因为我需要访问最后一个元素)?