tensorflow gfile文件操作

一、gfile模块:对文件进行操作

defined in tensorflow/python/lib/io/file_io.py

二:相关函数:

1. tf.gfile.Copy(oldpath, newpath, overwrite=False)

功能:从旧地址拷贝到新地址(Copies data from oldpath to newpath)

2. tf.gfile.DeleteRecursively(diename) recursively:递归地

功能:以递归的方式删除dirname下的所有内容(Deletes everything under the dirname recursively)

3. tf.gfile.Exists(filename)

功能:确定路径是否存在(Determines whether a path exists or not)

4. tf.gfile.Glop(filename)

功能:返回与给定模式匹配的文件列表(Returns a list of files that match the given pattern(s))

5. tf.gfile.IsDirectory(dirname)

功能:返回路径是否是目录(Returns whether the path is a directory or not)

6. tf.gfile.ListDirectory(dirname)

功能:返回目录中包含的条目列表。该列表按任意顺序排列。它不包含特殊条目'.' and '..'。(Returns a list of entries contained a directory)

returns: [filename1, filename2, ..., filenameN] as strings

7. tf.gfile.MakeDirs(dirname)

功能:创建目录和所有父/中间目录。如果dirname已存在且可写,则成功(Creates a directory and all parent/intermediate directories)

8. tf.gfile.MkDir(dirname)

功能:创建名为dirname的目录(Creates a directory with the name 'dirname')

和MakeDirs却别:MakeDirs是创建一连串的目录比如/data/sub1/;MkDir则是创建一个目录,比如/data/

9. tf.gfile.Remove(filename)

功能:删除位于'filename'的文件(Deletes the file located at 'filename')

10. tf.gfile.Rename(oldname, newname, overwrite=False)

功能:重命名或移动文件/目录(Rename or move a file / dirctory)

Args:

· overwrite: boolean,如果为False,则newname被现有文件占用是错误的(boolean, if false it is an error for newname to be occupied by an exiting file)

11. tf.gfile.Stat(filename)

功能:返回给定路径的文件统计信息(Returns file statistics for a given path)

Returns: FileStatistics 结构,包含有关路径信息(FileStatistics struct that contains information about the path)

12. tf.gfile.Walk(top, in_order=True)

功能:目录的递归目录生成器(Recursive directory tree generator for directories)

Args:

· top:string,a Nirectory name

· in_order:bool, Traverse(遍历) in order if True, post order if False

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值