考虑一下这段代码:
def test():
"""This line is longer than 80 chars, but, for me this is ok inside a DOCSTRING,
this one is shorter.
"""
if 'This is toooooooooooooooooooooooooooooooooooo longggggggggggggggggggggggg':
print 'True'
Run Code Online (Sandbox Code Playgroud)
pylint 输出:
C: 5, 0: Line too long (84/80) (line-too-long)
C: 9, 0: Line too long (83/80) (line-too-long)
Run Code Online (Sandbox Code Playgroud)
是否有任何指令 avaliable( rcfile)排除只 DOCSTRINGS从pylint检查?
一个多 regex对ignore-long-lines(感谢 @fredtantini)似乎被忽略.
周边文档字符串用# pylint: dis/enable=line-too-long(感谢 @Evert)将导致所要求的效果,不过,我正在寻找一个 …
我很难模仿这个简单的部分bash:
$ cat /tmp/fifo.tub &
[1] 24027
$ gunzip -c /tmp/filedat.dat.gz > /tmp/fifo.tub
line 01
line 02
line 03
line 04
line 05
line 06
line 07
line 08
line 09
line 10
[1]+ Done cat /tmp/fifo.tub
Run Code Online (Sandbox Code Playgroud)
基本上我尝试过这种subprocess方法:
# -*- coding: utf-8 -*-
import os
import sys
import shlex
import pprint
import subprocess
def main():
fifo = '/tmp/fifo.tub'
filedat = '/tmp/filedat.dat.gz '
os.mkfifo(fifo,0777)
cat = "cat %s" % fifo
args_cat = shlex.split(cat)
pprint.pprint(args_cat)
cat …Run Code Online (Sandbox Code Playgroud) 我有一个存储在 Pandas Dataframe 中的图像 URL 列表。我想下载所有这些图像并将它们存储在本地。
我用来执行此操作的代码是:
import os
import requests
def load(df, output_folder):
print("Ready to load "+str(len(df.index))+" images.")
for i,row in df.iterrows():
print("Image "+str(i))
save_image_from_url(row["image_url"], os.path.join(output_folder, row["image_name"]))
''' From a given URL, download the image and store it at the given path'''
def save_image_from_url(url, output_path):
image = requests.get(url)
with open(output_path, 'wb') as f:
f.write(image.content)
Run Code Online (Sandbox Code Playgroud)
问题是该过程非常慢(每个图像从 0.5 秒到 4 秒)。有没有办法做得更快?
我有一个4列大的制表符分隔.txt文件
col1 col2 col3 col4
name1 1 2 ens|name1,ccds|name2,ref|name3,ref|name4
name2 3 10 ref|name5,ref|name6
... ... ... ...
Run Code Online (Sandbox Code Playgroud)
现在我想从这个文件中提取以'ref |'开头的所有内容.此模式仅存在于col4中
所以对于这个例子,我希望得到输出
ref|name3
ref|name4
ref|name5
ref|name6
Run Code Online (Sandbox Code Playgroud)
我想过为这个使用'sed',但我不知道从哪里开始.
python ×3
awk ×1
concurrency ×1
linux ×1
pipe ×1
pylint ×1
sed ×1
subprocess ×1
web-scraping ×1