设为首页 收藏本站
查看: 1057|回复: 0

[经验分享] python文档自译:os模块-01【说明部分】

[复制链接]

尚未签到

发表于 2016-5-18 02:55:31 | 显示全部楼层 |阅读模式
15.1. os — Miscellaneous operating system interfaces
This module provides a portable way of using operating system dependent functionality. If you just want to read or write a file see open(), if you want to manipulate paths, see the os.path module, and if you want to read all the lines in all the files on the command line see the fileinput module. For creating temporary files and directories see the tempfile module, and for high-level file and directory handling see the shutil module.
 15.1. os — (各式各样的|多才多艺的)os接口
此模块提供了轻便使用OS的依赖功能。 
 
如果只想读写file,参见open();
如果想操作paths,参见os.path 模块;
如果你想从命令行读取所有文件的所有行,参见fileinput模块;
想创建临时files和directories,参见tempfile模块;
想要更高级的,处理file和directories的功能,参见shutil模块;

Notes on the availability of these functions:
The design of all built-in operating system dependent modules of Python is such that as long as the same functionality is available, it uses the same interface; for example, the function os.stat(path) returns stat information about path in the same format (which happens to have originated with the POSIX interface).
Extensions peculiar to a particular operating system are also available through the os module, but using them is of course a threat to portability.
An “Availability: Unix” note means that this function is commonly found on Unix systems. It does not make any claims about its existence on a specific operating system.
If not separately noted, all functions that claim “Availability: Unix” are supported on Mac OS X, which builds on a Unix core.
Note
All functions in this module raise OSError in the case of invalid or inaccessible file names and paths, or other arguments that have the correct type, but are not accepted by the operating system.

 关于这些函数的使用性说明:
 
1.python内置的OS依赖模块,它的设计是这样的:只要提供相同的功能,那么他们必定使用相同的接口。例如:函数os.stat(path)返回path同格式的stat信息。(恰似POSIX接口的起源。)
 
2.使用os模块,也可以使用特定OS的特定扩展,但从兼容性来讲,是个威胁。
 
3.如果有“Availability:Unix”这样的提示,意思是说,这个函数是Unix系统常见的。并不是说只在此特定的操作系统才能有。
 
4.如果没特殊说明,所有声张“Availability:Unix”的函数,都支持Mac OS X,它也是基于Unix内核的。
 
【注意】:如果file的names/paths无效,或无法访问,再或者参数类型也正确,但是无法被操作系统接收时,此模块的所有函数都会抛出OSError.

exception os.error
An alias for the built-in OSError exception.
os.name
The name of the operating system dependent module imported. The following names have currently been registered: 'posix', 'nt', 'os2', 'ce', 'java', 'riscos'.

 
 
  异常:
  os.error 内置的OSError exception的别名.
  os.name 导入的操作系统依赖模块的name. 当前注册了的名字有: 'posix', 'nt', 'os2', 'ce', 'java', 'riscos'.
  【译注:比如在windows7命令行print os.name,会回显:'nt'】
 

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-218322-1-1.html 上篇帖子: Mac下查看、添加path环境变量 下篇帖子: 分享---PHP获取MAC地址的实现代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表