Python os模块

os.name The name of the operating system dependent module imported.

os.devnull The file path of the null device. 不知道用法

##Environ os.environ A mapping object representing the string environment.

os.getenv(key, default=None) Return the value of the environment variable key if it exists, or default if it doesn’t. key, default and the result are str. os.environ[key]

os.pathsep The character conventionally used by the operating system to separate search path components (as in PATH)

os.sep The character used by the operating system to separate pathname components.

Path

os.getcwd() Return a string representing the current working directory.

Directory

os.listdir(path='.') Return a list containing the names of the entries in the directory given by path

os.mkdir(path, mode=0o777, *, dir_fd=None) Create a directory named path with numeric mode mode. If the directory already exists, FileExistsError is raised.

os.makedirs(name, mode=0o777, exist_ok=False) Recursive directory creation function. Like mkdir(), but makes all intermediate-level directories needed to contain the leaf directory.

File

os.remove(path, *, dir_fd=None) Remove (delete) the file path. If path is a directory, OSError is raised. Use rmdir() to remove directories.

os.stat(path, *, dir_fd=None, follow_symlinks=True) Get the status of a file or a file descriptor.

转载于:https://my.oschina.net/nohtyp/blog/760903

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值