Python releases version PYc script

Source: Internet
Author: User

ImportOSImportSYS fromPy_compileImportCompile#print "Argvs:", sys.argvifLen (sys.argv) = = 3: comd= Sys.argv[1] Path= Sys.argv[2]    ifOs.path.exists (PATH) andOs.path.isdir (path): forParent,dirname,filenameinchOs.walk (path): forCFileinchFilename:fullname=Os.path.join (parent,cfile)ifCOMD = =' Clean'  andCfile[-4:] = ='. PYc':                    Try: Os.remove (FullName)Print "Success Remove file:%s"%FullNameexcept:                        Print "Can ' t remove file:%s"%FullNameifCOMD = ='Compile'  andCfile[-3:] = ='. PY':                    Try: Compile (FullName)Print "Success Compile file:%s"%FullNameexcept:                        Print "Can ' t compile file:%s"%FullNameifCOMD = ='Remove'  andCfile[-3:] = ='. PY'  andCFile! ='settings.py':                    Try: Os.remove (FullName)Print "Success Remove file:%s"%FullNameexcept:                        Print "Can ' t remove file:%s"%FullNameElse:        Print "Not a directory or direcotry doesn ' t exist!"Else:    Print "Usage:"    Print "\tpython compile_pyc.py Clean path\t\t#to-all PYC files"    Print "\tpython compile_pyc.py compile path\t\t#to generate PYC files"    Print "\tpython compile_pyc.py Remove path\t\t#to remove py files"

Python releases version PYc script

Related Article

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.