python常用模块.pdf
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
Python os 模块详解 Python 的 os 模块提供了一个轻便的方法来使用依赖操作系统的功能。这个模块中关于 Unix 中的函数大部分都被略过,翻译主要针对 Windows。 os 模块的主要功能 1. 文件和文件夹操作:os 模块提供了多种文件和文件夹操作的方法,如 open()、os.path、fileinput、tempfile、shutil 等。 2. 环境变量操作:os.environ 是一个 mapping 对象,表示环境变量。可以通过 os.environ 获取和设置环境变量。 3. 进程和用户信息操作:os 模块提供了多种获取进程和用户信息的方法,如 os.getpid()、os.getuid()、os.getgid() 等。 4. 文件路径操作:os 模块提供了多种文件路径操作的方法,如 os.path、os.getcwd() 等。 os 模块的重要函数和变量 1. os.name:导入依赖操作系统模块的名字。当前注册的名字包括 'posix', 'nt', 'mac', 'os2', 'ce', 'java', 'riscos'。 2. os.environ:一个 mapping 对象,表示环境变量。 3. os.getcwd():返回当前工作目录。 4. os.chdir(path):改变当前工作目录。 5. os.fchdir(fd):改变当前工作目录。 6. os.ctermid():返回进程控制终端的文件名。 7. os.getegid():返回当前进程有效的 group 的 id。 8. os.geteuid():返回当前进程有效的 user 的 id。 9. os.getgid():返回当前进程当前 group 的 id。 10. os.getgroups():返回当前进程支持的 groups 的 id 列表。 11. os.getlogin():返回进程控制终端登陆用户的名字。 12. os.getpgid(pid):返回 pid 进程的 group id。 13. os.getpgrp():返回当前进程组的 id。 14. os.getpid():返回当前进程的 id。 15. os.getppid():返回当前父进程的 id。 16. os.getuid():返回当前当前进程用户的 id。 17. os.getenv(varname[, value]):返回 environment 变量 varname 的值。 18. os.putenv(varname, value):设置 varname 环境变量为 value 值。 os 模块的使用场景 1. 文件操作:使用 os 模块可以对文件进行读写、复制、删除等操作。 2. 文件夹操作:使用 os 模块可以对文件夹进行创建、删除、重命名等操作。 3. 环境变量操作:使用 os 模块可以获取和设置环境变量。 4. 进程和用户信息操作:使用 os 模块可以获取进程和用户的信息。 5. 文件路径操作:使用 os 模块可以对文件路径进行操作。 总结 os 模块是 Python 的一个重要模块,提供了多种操作系统相关的功能。通过使用 os 模块,可以对文件、文件夹、环境变量、进程和用户信息进行操作。
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/release/download_crawler_static/27188781/bg1.jpg)
![](https://csdnimg.cn/release/download_crawler_static/27188781/bg2.jpg)
![](https://csdnimg.cn/release/download_crawler_static/27188781/bg3.jpg)
![](https://csdnimg.cn/release/download_crawler_static/27188781/bg4.jpg)
![](https://csdnimg.cn/release/download_crawler_static/27188781/bg5.jpg)
剩余49页未读,继续阅读
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
- 粉丝: 14
- 资源: 26万+
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)