小编ant*_*tho的帖子

Difference between websocket and websockets

I don't understand the difference between websocket (websocket client) and websockets. I would like to understand the difference to know which one uses to be optimal.

I have a code that seems to do the same thing.

import websockets
import asyncio
import json

async def capture_data():
    uri = "wss://www.bitmex.com/realtime?subscribe=instrument:XBTUSD"
    #uri = "wss://www.bitmex.com/realtime"
    async with websockets.connect(uri) as websocket:
        while True:
            data = await websocket.recv()
            data = json.loads(data)
            try :
                #print('\n', data['data'][0]["lastPrice"])
                print('\n', data)
            except KeyError:
                continue


asyncio.get_event_loop().run_until_complete(capture_data())
Run Code Online (Sandbox Code Playgroud)
import websocket
import json …
Run Code Online (Sandbox Code Playgroud)

python websocket python-3.x python-asyncio

9
推荐指数
1
解决办法
1914
查看次数

不使用命名空间 std 就不能编译的程序;

我有一个编译器错误:

g++ main.cpp -o exec -Wall -std=c++17 -Wextra -pedantic -O2 -Wshadow -fsanitize=undefined
main.cpp: In instantiation of ‘std::__cxx11::string to_string(A) [with A = int; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
main.cpp:68:25:   required from ‘void debug_out(Head, Tail ...) [with Head = int; Tail = {}]’
main.cpp:79:3:   required from here
main.cpp:43:3: error: ‘begin’ was not declared in this scope
   for (const auto &x : v) {
   ^~~
main.cpp:43:3: note: suggested alternative:
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from main.cpp:1:
/usr/include/c++/7/valarray:1211:5: note:   ‘std::begin’
     begin(const valarray<_Tp>& __va)
     ^~~~~
main.cpp:43:3: error: …
Run Code Online (Sandbox Code Playgroud)

c++ templates c++11 c++17

0
推荐指数
1
解决办法
89
查看次数

标签 统计

c++ ×1

c++11 ×1

c++17 ×1

python ×1

python-3.x ×1

python-asyncio ×1

templates ×1

websocket ×1