小编use*_*432的帖子

Flask替代品可实现真正的多线程?

我使用Flask微框架实现了一个多线程Web服务器.基本上,我的服务器有一个任务队列和一个线程池.因此,它可以处理多个请求.由于Flask是用Python实现的,并且Python线程并不真正并发,我的Web应用程序有点滞后.

Flask有什么替代品可以解决多线程问题吗?

python multithreading flask

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

Python:UTF-8:如何计算 UTF-8 字符串中的单词数?

我需要计算 UTF-8 字符串中的单词数。即我需要编写一个Python函数,它需要“\xe0\xa4\x8f\xe0\xa4\x95\xe0\xa4\xac\xe0\xa4\xbe\xe0\xa4\xb0,\xe0\xa4\x8f\xe0 \xa4\x95\xe0\xa4\x95\xe0\xa5\x8c\xe0\xa4\x86、\xe0\xa4\xac\xe0\xa4\xb9\xe0\xa5\x81\xe0\xa4\xa4\xe0\ xa4\xaa\xe0\xa5\x8d\xe0\xa4\xaf\xe0\xa4\xbe\xe0\xa4\xb8\xe0\xa4\xbe, \xe0\xa4\xa5\xe0\xa4\xbe" 作为输入和返回 7(字数)。

\n\n

我尝试了正则表达式“\\b”,如下所示。但结果不一致。

\n\n
wordCntExp=re.compile(ur\'\\b\',re.UNICODE);\nsen=\'\xe0\xa4\x8f\xe0\xa4\x95 \xe0\xa4\xac\xe0\xa4\xbe\xe0\xa4\xb0,\xe0\xa4\x8f\xe0\xa4\x95 \xe0\xa4\x95\xe0\xa5\x8c\xe0\xa4\x86, \xe0\xa4\xac\xe0\xa4\xb9\xe0\xa5\x81\xe0\xa4\xa4 \xe0\xa4\xaa\xe0\xa5\x8d\xe0\xa4\xaf\xe0\xa4\xbe\xe0\xa4\xb8\xe0\xa4\xbe, \xe0\xa4\xa5\xe0\xa4\xbe\';\nprint len(wordCntExp.findall(sen.decode(\'utf-8\'))) >> 1;\n12 \n
Run Code Online (Sandbox Code Playgroud)\n\n

对上述答案的任何解释或解决上述问题的任何其他方法都值得赞赏。

\n

python string utf-8 hindi

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

标签 统计

python ×2

flask ×1

hindi ×1

multithreading ×1

string ×1

utf-8 ×1