python - Pylint 给我 "Final new line missing"

标签 python python-3.x pylint

Pylint 在我调用函数“deletdcmfiles()”的最后一行提示。 “缺少最后的换行符”。我是 python 的新手,我不确定是什么触发了这个?

程序代码如下:

'''
This program will go through all Work subdirectorys in "D:\\Archvies" folder
and delete all DCM files older then three months.
'''
import os.path
import glob
import time

#Create a list of Work directorys in Archive folder
WORKDIR = glob.glob("D:\\Archives\\ASP*\\Work*")
#Variable holds three months of time in seconds
THREEMONTHSOLD = (time.time()) - (90 * 86400)

def deletdcmfiles():
    '''
    This function will go through all Work subdirectorys in "D:\\Archvies" folder
    and delete all DCM files older then three months.
    '''
    #Variable to keep counter of deleted files
    deleted_files = 0
    #Loop through each Work subdirectory and delete all .DCM files older then 3 months
    for mydir in enumerate(WORKDIR):
        #Store all directory files in a list
        dcmfiles = glob.glob(mydir[1] + "\\" + "*.dcm")
        #Compare Modified Date of each DCM file and delete if older then 3 Months
        for file in enumerate(dcmfiles):
            if os.path.getmtime(file[1]) < THREEMONTHSOLD:
                print("Deleted " + file[1] + " " + time.ctime(os.path.getmtime(file[1])))
                os.remove(file[1])
                deleted_files += 1
    print("Total Files Deleted :" + str(deleted_files))

#Run program
deletdcmfiles()

最佳答案

您的文件末尾需要一个空的新行。只需在最后一行的末尾添加另一个 ENTER 就可以了。

关于python - Pylint 给我 "Final new line missing",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44317765/

相关文章:

python - Pandas如何通过在每列的任何行中获取值='yes'来组合行分组名称

python - 优化包含所有给定短语的句子

python - WTForms:IntegerField 跳过对字符串值的强制转换

python:无法从用户定义的函数返回 pandas 数据框(可能是用户错误)

Python 3 - 获取对象的定义路径

macos - 安装 pylint OSX 忽略可执行文件

django - 'staticmethod' 对象没有属性 'short_description'

python - 导入 Python 模块时遇到问题

python - python3 http请求中的TypeError : a bytes-like object is required,不是 'str'

python - Nose 工具和 pylint