小编adi*_*rof的帖子

使用PHPExcel时未启用ZipArchive库

我正在使用CodeIgniter和PHPExcel来读取和写入excel文件.

在localhost中一切正常,但是当我将我的PHP CodeIgniter应用程序上传到pagodabox中的服务器时,当我尝试从excel文件中读取数据时,我得到了以下消息.

Fatal error: Uncaught exception 'Exception' with message 'ZipArchive library is not enabled' in /var/www/application/libraries/PHPExcel/Reader/Excel2007.php
Run Code Online (Sandbox Code Playgroud)

php codeigniter pecl phpexcel ziparchive

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

Python池无法在Windows中工作,但可以在Linux中工作

我正在尝试在Windows 10 Intel Core i7-8550U处理器上使用Python 3.7.4进行python多处理。
我正在用两个函数测试多进程,一个函数使用基本sleep(),另一个函数使用sklearn的matthews_corrcoef。多重处理可使用睡眠功能,但不能使用sklearn功能。

import numpy as np
from sklearn.metrics import matthews_corrcoef
import time
import concurrent.futures
from multiprocessing import Process, Pool
from functools import partial
import warnings
import sys

class Runner():
  def sleeper(self, pred, man, thr = None):
    return time.sleep(2)

  def mcc_score(self, pred, man, thr = None):
    warnings.filterwarnings("ignore")
    return matthews_corrcoef(pred, man)

  def pool(self, func):
    t1 = time.perf_counter()
    p = Pool()
    meth = partial(func, pred, man)
    res = p.map(meth, thres)
    p.close()

    t2 = time.perf_counter()
    print(f'Pool {func.__name__} {round((t2-t1), 3)} …
Run Code Online (Sandbox Code Playgroud)

python windows scikit-learn python-multiprocessing python-pool

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

用于映射到自动递增整数值的键的 Python 数据结构

我想将字符串列表存储到字典数据结构中,其中键是我提供的字符串,值是自动递增计数。

text = ['hello', 'world', 'again']
ai_ds = {} # define the data structure here, used dict just for reference
ai_ds.add(text[0]) # should return 0
ai_ds.add(text[1]) # should return 1

auto_increment_ds.get(text[0]) # should return 0
Run Code Online (Sandbox Code Playgroud)

我可以通过保留手动计数器,然后在字典中插入值时使用它来做到这一点,但我想知道 python 中是否有像这样的默认数据结构。

python dictionary data-structures

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