python 文件操作 os.listdir() 遍历文件
生活随笔
收集整理的這篇文章主要介紹了
python 文件操作 os.listdir() 遍历文件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
功能:
返回所給路徑中所有文件(包含文件夾)的名稱列表
doc:
def listdir(*args, **kwargs): # real signature unknown"""Return a list containing the names of the files in the directory. 返回包含目錄中文件名的列表。path can be specified as either str, bytes, or a path-like object. If path is bytes,the filenames returned will also be bytes; in all other circumstancesthe filenames returned will be str.If path is None, uses the path='.'.On some platforms, path may also be specified as an open file descriptor;\the file descriptor must refer to a directory.If this functionality is unavailable, using it raises NotImplementedError.可以將路徑指定為str,字節或類似路徑的對象。 如果path是字節,則返回的文件名也將是字節; 在所有其他情況下,返回的文件名均為str。 如果path為None,則使用path ='.'。在某些平臺上,路徑也可以指定為打開的文件描述符; \文件描述符必須引用目錄。 如果此功能不可用,則使用它會引發NotImplementedError。The list is in arbitrary order. It does not include the specialentries '.' and '..' even if they are present in the directory.該列表是任意順序的。 它不包括特殊條目“.” 和“ ..”,即使它們存在于目錄中。"""pass參考文章:Python os.listdir() 方法
總結
以上是生活随笔為你收集整理的python 文件操作 os.listdir() 遍历文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python Intel Realsen
- 下一篇: websocket python爬虫_p