Python--os

Source: Internet
Author: User

Os.listdir (Path=none)

--Output All files under current path os.listdir ()

#不给参数默认输出当前路径下所有文件Os.stat (Path, *, Dir_fd=none, follow_symlinks=true)

--#查看文件状态信息 Follow_symlinks True returns information about the file itself, flase and, if it is a soft link, displays the soft link itself.

In [9]: Os.stat (' t1 ', follow_symlinks=false)

#如果follow_symlinks指定为False, and the last element of the path is a symbolic link, chmod modifies the symbolic link itself rather than the file that the link points to.

OUT[13]: Os.stat_result (st_mode=41471, st_ino=1423520, st_dev=64768, St_nlink=1, St_uid=0, St_gid=0, st_size=4, St_ atime=1509156724, st_mtime=1509156722, st_ctime=1509156722)

Os.chmod (path, mode, *, Dir_fd=none, follow_symlinks=true)

--Modify Permissions os.chmod (' test2 ', 0o777)

#修改权限os.chown (path, UID, GID, *, Dir_fd=none, follow_symlinks=true)

--Change the owner or group of the file, but need to have sufficient permissions (root?)

os.chown (' test2 ', 1001,1001)

os.getcwd () # get current working directory

os.path.abspath ('. ' ) ) #获得当前工作目录

Os.path.abspath ('.. ' ) ) #获得当前工作目录的父目录

Os.path.abspath (os.curdir) #获得当前工作目录

Python--os

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.