我正在使用 Visual Studio 代码尝试从 Binance 中提取蜡烛,但我不断收到以下错误:
ModuleNotFoundError: No module named 'binance.client'; 'binance' is not a package
Run Code Online (Sandbox Code Playgroud)
这是导致错误的代码行:
from binance.client import Client
Run Code Online (Sandbox Code Playgroud)
我已经确保我将 python-binance 安装到了正确的 python 版本,从我读到的内容来看,我猜测路径有问题,但我不确定要寻找什么。我运行以下代码检查路径
import pprint, os
import binance
pprint.pprint(os.path.abspath(binance.__file__))
Run Code Online (Sandbox Code Playgroud)
这是我的结果
'/Users/myName/.local/lib/python3.7/site-packages/binance.py'
Run Code Online (Sandbox Code Playgroud)
我读到,名为 binance.py 的文件可能会弄乱它,但这是下载时给出的名称。如果您对它的样子感到好奇,那就是:
import hmac
import hashlib
import logging
import requests
import time
try:
from urllib import urlencode
# for python3
except ImportError:
from urllib.parse import urlencode
ENDPOINT = "https://www.binance.com"
BUY = "BUY"
SELL = "SELL"
LIMIT = "LIMIT"
MARKET = "MARKET"
GTC = "GTC"
IOC …Run Code Online (Sandbox Code Playgroud) 我正在跟踪用户是否喜欢 firebase 中的餐厅,但我目前正在使用字符串来执行此操作。我知道可以在 Firebase 中更新数组,但根据我所读到的内容,为了执行此操作,每次要添加新元素时都需要重写整个数组。有什么方法可以将字符串附加到数组末尾吗?如果这是不可能的,有谁知道比仅使用字符串更好的替代方法吗?
这就是我现在正在使用的:
var likedBarsGlobal: [String] = [] {
didSet {
var lb = ""
for i in 1...likedBarsGlobal.count - 1 {
if(i == likedBarsGlobal.count - 1){
lb += "\(likedBarsGlobal[i])"
} else {
lb += "\(likedBarsGlobal[i]), "
}
}
db.collection("users").document(userId).updateData(["likedBars": lb ]) { (error) in
if error != nil {
print(error)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)