Python stunt Learning notes the next day

Source: Internet
Author: User

#coding =utf8
Import ZipFile
From threading Import Thread
Import Argparse
def extractfile (Zfile,password):
Try
Zipfile.extractall (pwd = password)
print ' Password is Found: ' + password
Except:
Pass

def main ():
Parser = Argparse. Argumentparser (usage= '%prog ' + '-f <zipfile>-D <dictionary> ')

Parser.add_argument ('-f ', Dest=zname, Type=argparse. FileType (' ZipFile '), help = ' Specify Zip file ')
Parser.add_argument ('-d ', Dest=dname, Type=argparse. FileType (' txt '), help = ' Specify Dictioary file ')

# (Argument,args) = Parser.parse_args ()
if (Zname = = None) | (dname = = None):
Print Parser.usage
Exit (0)
Else
Dname=argument.dname
Zname=argument.zname

Zfile = ZipFile. ZipFile (Zname)
Passfiles =open (dname)
For line in Passfiles.readlines ():
Password = line.strip (' \ n ')
t = Thread (target = extractfile, args = (Zfile,password))
T.start ()

If __name__== ' __main__ ':
Main ()

This is my new perfect code, but in the implementation of the total error, at present do not know how to solve the official documents, it is not clear how to interpret, if there is any big God understand these, I hope the generous enlighten, under the grateful.

Python stunt Learning notes the next day

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.