我写了一个小程序,比较了.then()
方法和async/await
方法之间的承诺的实现。代码运行正确,但是,输出的接收顺序出乎意料。有人可以解释为什么输出按当前顺序排列吗?
const backend = (num) => {
const someVar = new Promise((resolve, reject) => {
if (num % 2 === 0) {
resolve(`The number, ${num}, is even.`);
} else {
reject(`The number, ${num}, is odd.`);
}
})
return someVar;
}
const builtInFuncs = (num) => {
backend(num)
.then(message => console.log(message))
.catch(message => console.log(message));
}
const asyncAwait = async(num) => {
try {
const response = await backend(num);
console.log(response);
} catch (error) {
console.log(error);
}
}
builtInFuncs(2); …
Run Code Online (Sandbox Code Playgroud)我正在尝试将 AWS CLI 工具下载到我的 Mac 上。错误消息非常清楚Unsupported Python version detected: Python 2.7 To continue using this installer you must use Python 3.6 or later.
我遇到的问题是别名python
不起作用python3
。由于某种原因,在使用别名后,安装程序仍然引用Python 2.7
.
通过 cli 别名无法安装 AWS CLI 后,我将其添加alias python=python3
到我的.zshrc
文件中。运行python --version
返回Python 3.9.6
。运行 AWS 安装程序仍然引用旧版本的 python。
我对是否完全覆盖旧版本犹豫不决,因为我从多个来源了解到不应触及 OS X 上的默认 python。
有人可以解释一下在安装 AWS CLI 工具时如何引用较新版本的 python 吗?
macos command-line-interface amazon-web-services python-3.x aws-cli