我试图在二进制模式下使用websockets将二进制数据从用Python编写的服务器传输到客户端浏览器(运行javascript).我已经在文本模式下实现了这种通信,但现在我希望通过以二进制模式进行通信来提高性能.
我已经看到了所有的实施例(例如此,并且还如果一个通过其使用旋风matplotlib/webagg的源代码DIG),如权利要求他们正在使用二进制模式,但实际上它们似乎原始二进制数据编码成UTF-8(或者base64)在传输之前的某个时刻.在我看来,这不是真正的二进制传输,因为它增加了30%到50%的开销.
所以我的问题是,为了使用基于IP的websockets,是否必须将二进制数据编码为utf-8或base64?如果没有,请指出一个没有编码的例子.
我一直认为套接字确实支持真正的二进制通信,但由于某种原因,可能不是IP websockets的情况.也许有人可以阐明这个问题.在这一领域,过去一年左右似乎取得了进展,从而增加了混乱.
我已经开始学习F#了,我遇到的一件事是我不知道range用Python 表达相当于函数的方法.我知道[1..12]相当于范围(1,13).但我想要做的是range(3, 20, 2)(我知道Haskell [3,5..19]).我怎么表达这个?
我正在尝试在新的Ubuntu 16.04实例上设置Hakyll,但似乎无法正确理解基于堆栈的安装说明。
从开始stack install hakyll,我得到:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for hakyll-4.9.3.0:
http-conduit-2.1.11 must match >=2.2 && <2.3 (latest applicable is 2.2.3)
Plan construction failed.
Run Code Online (Sandbox Code Playgroud)
绑定到时stack-install http-conduit-2.1.11,出现了类似的错误:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for http-conduit-2.2.3:
http-client-0.4.31.2 must match >=0.5 && <0.6 (latest applicable is 0.5.5)
http-client-tls-0.2.4.1 must match >=0.3 && <0.4 (latest applicable is 0.3.3.1) …Run Code Online (Sandbox Code Playgroud) 我正在使用Rust中一个非常简单的HTTP客户端,它基于hyper(GitHub,crates.io)包.
当我尝试examples/client.rs使用cargo build(以及使用rustc src/main.rs)在新的Cargo项目中复制文件时,我会收到由导入失败导致的多个错误hyper.
这是我的最高层main.rs:
extern crate hyper;
use hyper::client::{Client, Request, Response, DefaultTransport as HttpStream};
use hyper::header::Connection;
use hyper::{Decoder, Encoder, Next};
Run Code Online (Sandbox Code Playgroud)
除了一些注释之外,文件的其余部分与存储库中的examples/client.rs文件相同hyper.
在编译时,我收到以下错误:
src/main.rs:10:48: 10:78 error: unresolved import `hyper::client::DefaultTransport`. There is no `DefaultTransport` in `hyper::client` [E0432]
src/main.rs:10 use hyper::client::{Client, Request, Response, DefaultTransport as HttpStream};
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:10:48: 10:78 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:12:13: 12:20 error: …Run Code Online (Sandbox Code Playgroud) 我已经设置了一些CSS来检测客户端是使用Retina还是其他HiDPI显示器,并根据它显示不同background-image的divs.这是我的语法:
<!-- LoDPI and MedDPI displays -->
#div {
opacity:0.4;
position:absolute;
top:0px;
z-index:2;
width:1600px;
height:900px;
animation-name:ring;
animation-delay:0s;
animation-duration:1500ms;
animation-timing-function:cubic-bezier(0.225, 1.650, 0.000, 0.805);
animation-fill-mode:forwards;
background-image:url(/valid/path/to/regular/file);
}
<!-- For Retina and HiDPI displays -->
@media only screen and (min-device-pixel-ratio: 1.4) {
#div {
background-image:url(/valid/link/to/HiDPI/file);
background-position:center;
background-size:contain;
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,当我在Retina MBP上尝试这一点时,其像素比率设置为1.5("就像1920x1200"),显示正常分辨率图像而不是高分辨率图像.
我最近无意中听到一个会话片段,其中一个人无休止地宣传JPG优于所有其他格式的优势.根据我的经验,PNG可以做更多的事情(透明度,更好的文本显示),同时使用相同数量的空间,如果不是更少,则使用相同源PSD,AI或原始捕获图像制作的JPG.
这让我思考; JPG实际上比PNG 有什么优势吗?
在过去两年左右的时间里,我已经为网络编码了多种类型的数据:图像,.otf文件,文本等等.它是实用的,它可以作为一种临时的资产整合方法(数据直接嵌入CSS或HTML中,人们不必担心死链接),但是使用这种方法有什么缺点吗?
我在Windows 8下运行VS 2010.安装NuGet并运行Package manager控制台后,我收到以下消息:
Error: The Package Manager Console requires PowerShell 2.0 runtime, which is not detected on this machine. Please install the PowerShell 2.0 from http://support.microsoft.com/kb/968929 and restart Visual Studio.
我知道PowerShell 3.0与Windows 8一起自动安装.为什么会弹出此错误消息?
我试图创建简单的python代码,通过他们的api https://www.9kw.eu/api.html#apisubmit-tab与9kw.eu captcha解决服务进行通信.基本上我用一些键发送base64编码的图像:服务器的值和响应应该是这样的数字:58952554,但我只是得到
<response[200]>
Run Code Online (Sandbox Code Playgroud)
这应该意味着服务器获取了我的数据,但我没有得到任何其他东西.我能用简单的html格式得到正确的结果:
<form method="post" action="https://www.9kw.eu/index.cgi" enctype="multipart/form-data">
KEY:<br>
<input name="apikey" value="APIKEY"><br>
ACTION<br>
<input name="action" value="usercaptchaupload"><br>
FILE:<br>
<input name="file-upload-01" value="BASE64IMAGEDATAHERE"><br>
TOOL<br>
<input name="source" value="htmlskript"><br>
ROTATE<br>
<input name="rotate" value="1"><br>
Angle<br>
<input name="angle" value="40"><br>
BASE64
<input name="base64" value="1"><br>
Upload:<br>
<input type="submit" value="Upload and get ID">
</form>
Run Code Online (Sandbox Code Playgroud)
这是python代码,应该做同样的事情:
import requests
import time
#base64 image encoding
with open("funcaptcha1.png", "rb") as f:
data = f.read()
filekodovany = data.encode("base64")
#captcha uploader
udajepost = {'apikey':'APIKEY','action':'usercaptchaupload','file-upload-01':filekodovany,'source':'pythonator','rotate':'1','angle':'40','base64':'1'}
headers = {'Content-Type':'multipart/form-data'}
r = requests.post('https://www.9kw.eu/index.cgi', data = udajepost)
print(r) …Run Code Online (Sandbox Code Playgroud) 我试图让Python来发送EOF信号(Ctrl+ DVIA) Popen()。不幸的是,我Popen()在 *nix-like 系统上找不到任何类型的信号参考。这里有人知道如何发送这样的EOF信号吗?另外,是否有任何关于要发送的可接受信号的参考?