Python-related module Learning 1. Processing file name module glob

Source: Internet
Author: User
Tags glob

>>> Import glob
>>> Dir (glob)
['_ All _', '_ builtins _', '_ Doc _', '_ file __', '_ name _', 'fnmatch', 'glob', 'glob1 ', 'has _ magic', 'Magic _ check', 'OS', 'Re']
>>> Help (glob)
Help on module glob:

Name
Glob-filename globbing utility.

File
D:/python24/lib/glob. py

Functions
Glob (pathname)
Return a list of paths matching a pathname pattern.

The pattern may contain simple shell-style wildcards a la fnmatch.

data
_ all _ = ['glob']

its main method is glob, it is very convenient to process a batch of file names in the script, for example:
>> glob. glob ("C: //")
['C: // ']
glob. glob ("C: // *")
['C: // arcldr.exe ', 'c: // arcsetup.exe', 'c: // boot. INI ', 'c: // bootfont. bin', 'c: // cmd.txt ', 'c: // command. com ', 'c: // config. sys ', 'c: // debug_trace.txt', 'c: // devtools ', 'c: // dfimb. dat ', 'c: // documents and settings', 'c: // intel', 'c: // Io. sys ', 'c: // msdos. sys ', 'c: // msocache', 'c: // ntdetect. com ', 'c: // ntldr', 'c: // pagefile. sys ', 'c: // program files', 'c: // recycled ', 'c: // recycler', 'c: // response.txt ', 'c: // RT ', 'c: // suhdlog. dat ', 'c: // system volume information', 'c: // useprint. bat ', 'c: // videorom. bin', 'c: // Windows', 'c: // wmpub ', 'c: // wutemp']
>> glob. glob ("C ://*. TXT ")
['C: // example .txt ', 'c: // debug_trace.txt', 'c: // response.txt ']

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.