2017-06-01 6 views
7

पिलिंट अंतिम पंक्ति पर शिकायत करता है जहां मैं फ़ंक्शन "deletdcmfiles()" कह रहा हूं। "अंतिम नई लाइन लापता"। मैं अजगर के लिए नया हूँ और मुझे यकीन नहीं है कि यह क्या चल रहा है? आप अपनी फ़ाइल के अंत में एक खाली नई लाइन की जरूरत हैपिलिंट मुझे "अंतिम नई लाइन लापता" दे रहा है

''' 
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() 
+1

यह फ़ाइल के अंत में एक अतिरिक्त न्यूलाइन चरित्र की अपेक्षा करता है। फ़ाइल में निहित पायथन कोड के साथ वास्तव में कुछ भी नहीं है। – mkrieger1

+0

धन्यवाद कि इसे हल किया गया। –

उत्तर

9

:

यहाँ कार्यक्रम का कोड है। अंतिम लाइन के अंत में बस दर्ज करें और आप ठीक होंगे।

+1

धन्यवाद, यह चाल है। :) –

संबंधित मुद्दे