<div>
<button id="jsfetch">fetch json</button>
</div>
document.querySelector("#jsfetch").addEventListener("click", Handler);
function Handler(event) {
fetch('/api')
.then((response) => {
return response.json();
})
.then((myjson) => {
console.log(myjson);
});
}
from flask import jsonify
data = {
"id": 123,
"name": "Вася",
"surname": "Пупкин"
}
@app.route('/api')
def api():
return jsonify(data)
Object { id: 123, name: "Вася", surname: "Пупкин" }
wget -r -k -l 7 -p -E -nc http://site.com/
import msvcrt, sys
while True:
#тут что то делаем
if msvcrt.kbhit(): #если нажата клавища
k = ord(msvcrt.getch()) #считываем код клавиши
if k == 27: # если клавиша Esc
sys.exit() # завершаем программу
Platform.runLater((() -> someLabel.setText("Hello"));
public class Example extends Application {
...
btn.setOnAction(act -> {
Service<Void> service = new Service<Void>() {
@Override
protected Task<Void> createTask() {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
// Долгий код
return null;
}
};
}
};
service.start();
});
}
m1
в примере) можно пользоваться его нестатическими методами откуда угодно. s = '0.00009011'
first, second = s.split('.')
result = first + '.' + second[2:-2]
print(result)
float_number = 0.0000550034
print(f"{float_number:.nf}")
import numpy as np
number = 0.00009011
first, second = str(np.format_float_positional(number,trim='-')).split('.')
result = first + '.' + second[2:-2]
print(result)
здесь в отличии от первого случая тип наших float но проблема все равно решается.
API-keys are passed into the Rest API via the X-MBX-APIKEY header.
curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'
private void runCmdWithProgress(String... args) throws IOException {
Process proc = Runtime.getRuntime().exec(args);
InputStream inputStream = proc.getErrorStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String s = null;
while ((s = bufferedReader.readLine()) != null) {
Double progress = Double.parseDouble(s.split("%")[0]) / 100;
Platform.runLater(() -> tab_adb_progressbar.setProgress(progress));
}
try {
proc.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
new Thread(() -> {
try {
runCmdWithProgress(commands);
Platform.runLater(() -> showDialogInformation(positive);
} catch (IOException e) {
e.printStackTrace();
}
}).start();
byte[] arBytes;
...
ImageIcon icon = new ImageIcon(arBytes);
BufferedImage image = ImageIO.read(new ByteArrayInputStream(arBytes));
int[] arInts = {0,1,2,3,4,5,6,7,8,9};
...
BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = img.createGraphics();
g2d.setPaint(Color.red);
g2d.setFont(new Font("Serif", Font.BOLD, 18));
FontMetrics fm = g2d.getFontMetrics();
int x = 5;
for(int i : arInts){
String s = (new Integer(i)).toString();
g2d.drawString(s, x, 5);
x += fm.stringWidth(s) + 5;
}
g2d.dispose();