小编Vin*_*ais的帖子

计算两个文件中行差异的最有效方法是什么?

我有蟒蛇两个列表list_alist_b.在list_a有一些图片的链接,和list_b也.99%的项目是相同的,但我必须知道这1%.所有剩余物品都在list_a,这意味着所有物品list_b都在list_a.我最初的想法是减去所有项目: list_a - list_b = list_c,这list_c是我的剩余项目.我的代码是:

list_a = []
list_b = []
list_c = []

arq_b = open('list_b.txt','r')
for b in arq_b:
    list_b.append(b)

arq_a = open('list_a.txt','r')
for a in arq_a:
    if a not in arq_b:
        list_c.append(a)

arq_c = open('list_c.txt','w')
for c in list_c:
    arq_c.write(c)
Run Code Online (Sandbox Code Playgroud)

我认为逻辑是正确的,如果我有一些项目,代码运行得很快.但我没有10项,或1.000,甚至100.000.78.514.022list_b.txt78.616.777我的列表中有项目list_a.txt.我不知道这个表达的代价:if a not in arq_b.但如果我执行此代码,我认为今年不会完成.

我的电脑有8GB,我分配15GB的交换,以免爆炸我的RAM.

我的问题是,还有另一种方法可以使这项操作更有效(更快)吗?

  • list_a …

python performance list python-3.x difference

21
推荐指数
2
解决办法
1152
查看次数

如何在 InfluxDB 中设置身份验证?

我在 InfluxDB 中遇到了设置身份验证的问题。首先,以下教程告诉我更改配置文件:

https://docs.influxdata.com/influxdb/v1.7/administration/authentication_and_authorization/#set-up-authentication

[http]
  enabled = true
  bind-address = ":8086"
  auth-enabled = true # ?
  log-enabled = true
  write-tracing = false
  pprof-enabled = false
  https-enabled = false
  https-certificate = "/etc/ssl/influxdb.pem"
Run Code Online (Sandbox Code Playgroud)

但是当我更改并重新加载服务器时。我无法创建用户。

 CREATE USER paul WITH PASSWORD 'timeseries4days' WITH ALL PRIVILEGES
 ERR: unable to parse Basic Auth credentials
 Warning: It is possible this error is due to not setting a database.
 Please set a database with the command "use <database>".
Run Code Online (Sandbox Code Playgroud)

因此,当使用我创建的数据库时:

 USE example
 ERR: unable to parse Basic Auth credentials …
Run Code Online (Sandbox Code Playgroud)

influxdb

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

有没有快速将图像转换为 WEBP 的方法?

在我的网站中,我现在将上传的图像转换为 webp,因为它比其他格式小,用户会更快地加载我的页面(也是移动用户)。但转换中等图像需要一些时间。

import StringIO
import time

from PIL import Image as PilImage

img = PilImage.open('222.jpg')

originalThumbStr = StringIO.StringIO()

now = time.time()
img.convert('RGBA').save(originalThumbStr, 'webp', quality=75)
print(time.time() - now)
Run Code Online (Sandbox Code Playgroud)

转换以下图像需要 2.8 秒:

860KB,1920 x 1080

我的内存是 8GB RAM,处理器为 4 核(Intel I5),没有 GPU。

我在用着Pillow==5.4.1

有没有更快的方法可以更快地将图像转换为 WEBB。2,8秒,看来等的时间太长了。

在此输入图像描述

image-conversion python-imaging-library python-2.7

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

如何在flutter中发出本地http请求?

我正在制作一个应用程序,并且我已经在本地运行了一台服务器。我可以通过我的导航器访问网址:

Request URL: http://localhost:4444/categorie?page_size=15&page=1
Request Method: GET
Status Code: 200 OK
Remote Address: 127.0.0.1:4444
Referrer Policy: no-referrer-when-downgrade
Run Code Online (Sandbox Code Playgroud)

预览:

{
    "count": 4,
    "next": null,
    "previous": null,
    "results": [
        {
            "uid": "_b656062d3754",
            "name": "Pinga"
        },
        {
            "uid": "_0c644473c244",
            "name": "Cerveja"
        },
        {
            "uid": "_75df557ccbaa",
            "name": "Vinhos"
        },
        {
            "uid": "_8e32ce3baded",
            "name": "Refrigerantes"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试颤动时,请求从不响应:

getCategories() async {

  String url = 'http://localhost:4444/categorie?page_size=15&page=1';

  var response = await http.get(url);

  if (response.statusCode == 200) {
    // If the call to the server was successful, …
Run Code Online (Sandbox Code Playgroud)

django flutter

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