• 大小: 4.14MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-12
  • 语言: Python
  • 标签: python  unix  linux  system  

资源简介

Python is an ideal language for solving problems, especially for Linux and Unix. With this pragmatic book, administrators can review various tasks that often occur in the management of these systems, and learn how Python can provide a more efficient way to handle them. Once you finish this book, you

资源截图

代码片段和文件信息

#!/usr/bin/env python
import optparse
import os

def main():
    p = optparse.OptionParser(description=“Python ‘ls‘ command clone“
                                prog=“pyls“
                                version=“0.1a“
                                usage=“%prog [directory]“)
    p.add_option(“--chatty“ “-c“ action=“store“ type=“choice“
                    dest=“chatty“
                    choices=[“normal“ “verbose“ “quiet“]
                    default=“normal“)
    options arguments = p.parse_args()
    print options
    if len(arguments) == 1:
        if options.chatty == “verbose“:
            print “Verbose Mode Enabled“
        path = arguments[0]
        for filename in os.listdir(path):
            if options.chatty == “verbose“:
                print “Filename: %s “ % filename
            elif options.chatty == “quiet“:
                pass
            else:
                print filename
    else:
        p.print_help()
if __name__ == ‘__main__‘:
    main()

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2008-10-24 14:07  code\
     文件        6148  2008-10-24 14:07  code\.DS_Store
     目录           0  2008-10-24 14:07  __MACOSX\
     目录           0  2008-10-24 14:07  __MACOSX\code\
     文件          82  2008-10-24 14:07  __MACOSX\code\._.DS_Store
     目录           0  2008-10-24 14:05  code\.svn\
     文件          86  2008-10-24 14:05  code\.svn\all-wcprops
     文件         463  2008-10-24 14:05  code\.svn\entries
     文件           2  2008-10-24 14:05  code\.svn\format
     目录           0  2008-10-24 14:05  code\.svn\prop-base\
     目录           0  2008-10-24 14:05  code\.svn\props\
     目录           0  2008-10-24 14:05  code\.svn\text-base\
     目录           0  2008-10-24 14:05  code\.svn\tmp\
     目录           0  2008-10-24 14:05  code\.svn\tmp\prop-base\
     目录           0  2008-10-24 14:05  code\.svn\tmp\props\
     目录           0  2008-10-24 14:05  code\.svn\tmp\text-base\
     目录           0  2008-10-24 14:05  code\commandline\
     目录           0  2008-10-24 14:05  code\commandline\.svn\
     文件          98  2008-10-24 14:05  code\commandline\.svn\all-wcprops
     文件         285  2008-10-24 14:05  code\commandline\.svn\entries
     文件           2  2008-10-24 14:05  code\commandline\.svn\format
     目录           0  2008-10-24 14:05  code\commandline\.svn\prop-base\
     目录           0  2008-10-24 14:05  code\commandline\.svn\props\
     目录           0  2008-10-24 14:05  code\commandline\.svn\text-base\
     目录           0  2008-10-24 14:05  code\commandline\.svn\tmp\
     目录           0  2008-10-24 14:05  code\commandline\.svn\tmp\prop-base\
     目录           0  2008-10-24 14:05  code\commandline\.svn\tmp\props\
     目录           0  2008-10-24 14:05  code\commandline\.svn\tmp\text-base\
     目录           0  2008-10-24 14:05  code\commandline\code\
     目录           0  2008-10-24 14:05  code\commandline\code\.svn\
     文件        1918  2008-10-24 14:05  code\commandline\code\.svn\all-wcprops
............此处省略1598个文件信息

评论

共有 条评论