小编Hit*_*try的帖子

如何从字符串中删除空格?

在ubuntu bash脚本中如何从一个变量中删除空格

字符串将是

   3918912k 
Run Code Online (Sandbox Code Playgroud)

想要删除所有空白区域.

bash shell

51
推荐指数
5
解决办法
18万
查看次数

如何使用wireshark调试websockets

我已经在localhost ws:// localhost:8001上使用python tornado服务器托管我的websocket服务器,而客户端在192.168.0.116上的另一个系统上,所以当我们尝试通信它工作正常但无法使用wireshark调试它.我的websocket在端口8001上运行,所以我尝试使用

tcp.port==8001
Run Code Online (Sandbox Code Playgroud)

但没有找到结果,所以我在http上尝试了它我在LAN中的ip是192.168.0.219和端口8001.所以

http.host == 192.168.0.219 && tcp.port == 8001
Run Code Online (Sandbox Code Playgroud)

但没有找到结果.还有什么我可以尝试调试我的websocket.

wireshark websocket

19
推荐指数
2
解决办法
3万
查看次数

如何使用python从mongoDB中的10亿个文档中获取随机单个文档?

我想要来自mongoDB集合的单个随机文档.现在我的mongoDB集合包含超过10亿个集合.如何从该集合中获取单个随机文档?

python mongodb pymongo

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

在瓶子中使用POST方法时不允许405方法

我正在为强制下载开发一个简单的代码现在问题是我在GET方法中没有收到任何错误但在post方法请求中收到错误"405 Method Not Allowed".我的GET方法代码.

@route('/down/<filename:path>',method=['GET', 'POST'])
    def home(filename):
        key = request.get.GET('key')
        if key == "tCJVNTh21nEJSekuQesM2A":        
            return static_file(filename, root='/home/azoi/tmp/bottle/down/', download=filename)
        else:
    return "File Not Found"
Run Code Online (Sandbox Code Playgroud)

当我用密钥请求它时,它返回我的文件下载,当它是获取方法 http://mydomain.com/down/xyz.pdf?key=tCJVNTh21nEJSekuQesM2A

现在我使用另一个代码来处理POST方法

@route('/down/<filename:path>',method=['GET', 'POST'])
    def home(filename):
        key = request.body.readline()
        if key == "tCJVNTh21nEJSekuQesM2A":        
            return static_file(filename, root='/home/azoi/tmp/bottle/down/', download=filename)
        else:
            return "File Not Found"
Run Code Online (Sandbox Code Playgroud)

现在通过使用此代码我无法处理post方法,即我从服务器获得405 Method Not Allowed错误.

对此有何解决方案?

python bottle

6
推荐指数
1
解决办法
1万
查看次数

在芹菜中如何获取特定任务名称的所有任务的任务状态?

celery中,我想获取特定任务名称的所有任务的任务状态.对于尝试下面的代码.

import celery.events.state

# Celery status instance.
stat = celery.events.state.State()

# task_by_type will return list of tasks.
query = stat.tasks_by_type("my_task_name")

# Print tasks.
print query
Run Code Online (Sandbox Code Playgroud)

现在我在这段代码中得到空列表.

python celery celery-task celeryd

6
推荐指数
1
解决办法
1584
查看次数

如何在没有过期的情况下生成文件链接?

在AWS S3中,如何为文件生成文件下载URL而不会过期.

conn = boto.connect_s3(awsAccessKey, awsSecret)

# Get bucket instance.
bucket = conn.get_bucket(bktName)

fileKey = bucket.get_key(fileKey)
url = fileKey.generate_url(expires_in=None, query_auth=True, force_http=True)
print url
Run Code Online (Sandbox Code Playgroud)

如何为文件生成url而没有到期?

python amazon-s3 amazon-ec2 boto amazon-web-services

5
推荐指数
2
解决办法
1733
查看次数

亚马逊SQS(简单排队服务)速度?

什么是排队的Amazon SQS(简单排队服务)的速度,格式如每秒n MB/KB.

amazon-sqs amazon-web-services

4
推荐指数
1
解决办法
2523
查看次数

将简单的PHP代码转换为python

我想将我的PHP代码转换为python代码.可能吗

$secret = 'segredo'; // To make the hash more difficult to reproduce.
$path   = '/p/files/top_secret.pdf'; // This is the file to send to the user.
$expire = 1096891200; // At which point in time the file should expire. time() + x; would be the usual usage.
$md5 = base64_encode(md5($secret . $path . $expire, true)); // Using binary hashing.`$md5 = strtr($md5, '+/', '-_'); // + and / are considered special characters in URLs, see the wikipedia page linked in references. …
Run Code Online (Sandbox Code Playgroud)

php python

3
推荐指数
1
解决办法
521
查看次数