|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
如题,看了一下相关内容:
os.getcwd() 获取当前工作目录,即当前python代码工作的目录路径。
os.curdir 返回当前目录: ('.') ??这个比较难理解。是否有通俗的方式来说说‘.’怎么就能代表当前目录了?类似的os.pardir用‘..’来代替上一层目录。
如果在idle上输入上述命令,可以看到上述命令的返回值不一样。
如果用os.listdir的命令,下述三种表达方式返回值相同:
1.os.listdir(os.getcwd())
2.os.listdir(os.curdir)
3.os.listdir()
用Idle逐个命令输出验证过,应该是等价的吧??
另外,通过help(os.curdir)返回: #这部分没读懂啊
Attribute references
********************
An attribute reference is a primary followed by a period and a name:
attributeref ::= primary "." identifier
The primary must evaluate to an object of a type that supports
attribute references, which most objects do. This object is then
asked to produce the attribute whose name is the identifier. This
production can be customized by overriding the "__getattr__()" method.
If this attribute is not available, the exception "AttributeError" is
raised. Otherwise, the type and value of the object produced is
determined by the object. Multiple evaluations of the same attribute
reference may yield different objects.
Related help topics: getattr, hasattr, setattr, ATTRIBUTEMETHODS, FLOAT,MODULES, OBJECTS
通过help(os.getcwd)返回: 这部分比较易懂
Help on built-in function getcwd in module nt:
getcwd()
Return a unicode string representing the current working directory.
|
|