尝试编写一个代码来比较多个文件并返回多个选项之间的最高模糊比。
问题是我收到一条错误消息:
警告:根:应用处理器将输入查询减少为空字符串,所有比较得分为 0。[查询:'/'] 警告:根:应用处理器将输入查询减少为空字符串,所有比较得分为 0。[查询: '.']
而且导出的文件基本上是空白的。知道为什么会发生这种情况吗?
from fuzzywuzzy import fuzz, process
import csv
def readfile( filen ):
with open(filen,'r') as f:
contents = f.readlines()
return contents
def write_fuzzy( fileo, file1, file2 ):
matches=[]
for item1 in file1:
matches.append(process.extract( str(item1), file2, limit=2 )[0][0])
with open( fileo, 'w' ) as f:
w = csv.writer( f, delimiter = ',' )
w.writerows( matches )
filenames = ['Documents/test_CSV_1.csv',\
'Documents/test_CSV_2.csv']
file_contents = []
for filen in filenames:
file_contents.append( readfile( filen ) )
write_fuzzy( 'out.csv', …Run Code Online (Sandbox Code Playgroud) 在查看了如何命名 Dockerfiles 的答案后,我仍然有很多问题。
就我而言,我至少需要两个Dockerfiles, adocker-compose.yaml和 a .dockerignore。听起来像是使用诸如<purpose>.Dockerfile或 之类的扩展Dockerfile.<purpose>,其缺点是失去在 hub.docker.com 上使用 autobuilder 的功能。
因此其他人建议您将每个文件保存Dockerfile在一个目录中并从那里构建。
所以也许是这样的:
dockerfiles/
--python_consumer/
-----Dockerfile
--python_producer/
-----Dockerfile
--docker-compose.yaml
--.dockerignore
Run Code Online (Sandbox Code Playgroud)
在这种情况下,.dockerignore 是否可以在全局范围内适用于所有 dockerfile?以这种方式构建有什么大的缺点吗?
我的示例 docker-compose.yaml 没有单独的目录和一个组合的消费者/生产图像作为上下文。
version: '3.8'
services:
standalone:
hostname: standalone
container_name: standalone
image: apachepulsar/pulsar:2.8.1
ports:
- 8080:8080 # exposed would be a better practice
- 6650:6650 # exposed would be a better practice
command: bin/pulsar standalone
healthcheck:
test: ["CMD", "nc", "-vz", "localhost", "6650"]
interval: 20s …Run Code Online (Sandbox Code Playgroud) 在链接列表类中,我创建了一个display方法来打印链接列表,因为它当前的形式如下:
void LinkedList::display() {
Node* curr = m_head;
while (curr) {
std::cout << curr->n_data << " -> ";
curr = curr->n_next;
}
std::cout << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
一位对作业进行评分的助教留下了评论:
切勿在类文件中执行 cout。
ostream& operator<<代替使用。类不应该关心输出到哪里(文件/控制台/等)。
在这次作业时我们还没有了解运算符重载,但我仍然不太确定。
我将如何实际实现并使用它ostream& operator>>来打印到控制台?为什么这是最佳实践?