小编Zoh*_*air的帖子

Python 中的 grep 等价物是什么?

假设我有一个带有“我喜欢大象”行的文本文件。如果我将上述文件和管道传送到“grep 大象”,我会得到整行“我喜欢大象”。

如何使用 re 在 Python 中实现此功能?我一直在尝试以下方法:

test = re.search('elephants', 'I like elephants.\nThey are nice')
test.group(0)
Run Code Online (Sandbox Code Playgroud)

我只得到“大象”这个词,而不是整个句子作为输出。

我如何得到整个句子?谢谢你。

python regex

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

ImageIO 中的质量损失

我有一系列高分辨率图像,我想使用 ImageIO 在 Python(3.6) 中将其转换为 MP4 文件。有没有什么办法可以在不压缩或不损失质量的情况下做到这一点?

目前我使用的代码:

fileList = []
path = "./Images/MP4/relu-3layers-32units-M1/"
name = "img"
for file in os.listdir(path):
    if file.startswith(name):
        complete_path = path + file
        fileList.append(complete_path)

 writer = imageio.get_writer('test.mp4', fps = 30)

 for im in fileList:
      writer.append_data(imageio.imread(im))
 writer.close()
Run Code Online (Sandbox Code Playgroud)

它生成视频,但质量大大降低。有任何解决这个问题的方法吗?

video python-3.x python-imageio

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

标签 统计

python ×1

python-3.x ×1

python-imageio ×1

regex ×1

video ×1