Py file path

Source: Internet
Author: User
Tags glob

#-*-Coding: UTF-8 -*-
"""
Start with #-*-coding: UTF-8 -*-
Or #-*-coding: cp936-*-otherwise, an error is returned.
"""

Import OS
Import glob
Import time

"""
To separate the paths, the split () function Windows system must also add a double line in the import OS header file.

"""

Pathname = "E: // first // SRC // text. py"
(Dirname, filename) = OS. Path. Split (pathname)

Print pathname
Print dirname
Print filename

"""
List contents import glob
The glob module is another tool in the python standard library. It can obtain the contents of a directory through programming.
And it uses wildcards in the familiar command line. The glob module uses shell-style wildcards.
Find the file name with the suffix ". py" in the current directory and the file name with the 'test' in the file name.
"""
# Print glob. glob (r'e:/First/src/*. py '),
Print
Print glob. glob ('*. py '),
Print
Print glob. glob ('* test *. py ')
Print

"""
Get object meta
Getcwd (): Get the directory reference OS in the current working environment.
"""
Print (OS. getcwd ())
Print

 

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.