Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Python Dir find a folder several files     - SSH security note (Linux)

- MySQL 5.7.10 source code for the latest version of the installation process in detail (Database)

- Wine 1.7 is installed on a system based on RedHat or Debian (Linux)

- Linux five security TIPS (Linux)

- Golang environment configuration recommendations (Linux)

- Linux C source code (sockettype: socket descriptor determination function) (Programming)

- How to install Linux Kernel 4.4 on Ubuntu (Linux)

- Using Linux command line and execute PHP code (Programming)

- Ubuntu users install the Download Manager software Xdman 5.0 (Linux)

- Elaborate .NET Multithreading: Thread Pool (Programming)

- How to Install SeaMonkey 2.25 for Ubuntu (Linux)

- CentOS yum install LNMP PHP5.4 version (Server)

- Depth understanding of C language (Programming)

- Nginx version information hidden or modified (Server)

- Install the latest Eclipse IDE in Ubuntu (Linux)

- CentOS 7 Change Hostname (Linux)

- Build ftp server under CentOS 6.5 (Server)

- ActiveMQ memory settings and flow control (Linux)

- Help you to see Linux system architecture type 5 Common Commands (Linux)

- CentOS 7.0 Automatic installation CD-ROM production Comments (Linux)

 
         
  Python Dir find a folder several files
     
  Add Date : 2017-08-31      
         
         
         
  Preface: colleagues encountered a problem and needs to find the file in 7000 tens of thousands of documents, messy. I checked the Python relevant information, although not completely resolved, but there are still things recorded.

First, for a folder through the file, os.walk can be broken. If multiple folders, then, with isdir, isfile and other functions can be broken (parameter optional):

for i in os.walk (os.getcwd (), topdown = True, onerror = None, followlinks = False):
    print i

os.path under judging function:
exists () Specifies the path (file or directory) exists
isabs () Specifies whether the path is an absolute path
isdir () Specifies whether the path exists and is a directory
isfile () Specifies whether a file exists and the path is
islink () Specifies whether the path exists and is a symbolic link
ismount () Specifies whether the path exists and is a mount point
samefile () whether two paths point to the same file name

Such returns i [3] for the list of file names, but I do not know what order, it is necessary to sort based on the file information, and to see how you need, how to sort.
For example, to sort the file has access time:

for i in os.walk (os.getcwd (), topdown = False):
    for j in i [2]:
        print j, os.path.getctime (j)

In os.path, the following functions on the file information:

getatime () Returns the last access time (float Seconds)
getctime () returns the file creation time
getmtime () returns the most recent file modification time
getsize () Returns the file size (in bytes)
abspath () returns the absolute pathname
normpath () path specification string
Obtain specific information, like the rest of the deal. sorted sorting function can be broken, the focus is not here, temporarily introduced.
     
         
         
         
  More:      
 
- Elasticsearch Kibana installation notes (Linux)
- Thinking in Java study notes - initialization and cleanup (Programming)
- Oracle 11g dataguard main library backup and recovery to the test environment in one database error (Database)
- Migrate Oracle database files to ASM (Database)
- Android components series Activity (Programming)
- JavaScript prototype and prototype chain and project combat (Programming)
- Linux ldconfig command (Linux)
- Oracle: RETURNING clause (Database)
- How to install Laravel PHP framework on CentOS 7 / Ubuntu 15.04 (Server)
- Use mysqldump MySQL database backup - Linux Shell Scripting (Database)
- Eclipse, Tomcat configuration JNDI connection Oracle data source example (Server)
- How to turn Java String into Date (Programming)
- How to Install Telegram instant messaging software on Ubuntu (Linux)
- Nodejs command-line program development tutorial (Programming)
- The next key to install Linux bash script PowerShell (Linux)
- Secondary exponential smoothing prediction method implemented in Python (Programming)
- MySQL appears data too long for column 'name' at row 1 to solve (Database)
- Nonstandard IMP-00010 error processing one case (Database)
- Ubuntu derivative version of the user and how to install SmartGit / HG 6.0.0 (Linux)
- Inherent limitations of Linux systems network security (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.