Tf.gfile () function

Source: Internet
Author: User

Turn from 80557958

These functions are very similar to the OS modules in Python and can generally be replaced with OS modules.

Gfile API Introduction

Each of the gfile is described below api!

2-1) tf.gfile.Copy (OldPath, NewPath, Overwrite=false)

Copy the source file and create the target file, no return, and its formal parameters are as follows:

OldPath: Copy source file with path name;

NewPath: Copy target file with path name;

Overwrite: Whether to overwrite when the target file already exists, False if the target file already exists

2-2) Tf.gfile.MkDir (dirname)

Create a directory, dirname the directory name, no return.

2-3) tf.gfile.Remove (filename)

Delete the file, filename is the file name, no return.

2-4) tf.gfile.DeleteRecursively (dirname)

Recursively deletes all directories and their files, DirName is the directory name, no return.

2-5) tf.gfile.Exists (filename)

Determines whether the directory or file exists, filename can be a directory path or a path with a file name, and the directory returns True, otherwise false.

2-6) Tf.gfile.Glob (filename)

Finds the file that matches the pattern and returns it as a list, which can be either a specific file name or a regular expression that contains wildcards.

2-7) tf.gfile.IsDirectory (dirname)

Determines whether the given directory exists, returns True if it exists, otherwise returns False,dirname is the directory name.

2-8) tf.gfile.ListDirectory (dirname)

Lists all the files in the DirName directory and returns them as a list, dirname must be a directory name.

2-9) Tf.gfile.MakeDirs (dirname)

The parent directory and its subdirectories are built recursively, and if the directory already exists and is overwritten, it is created successfully, otherwise an error is not returned.

2-10) Tf.gfile.Rename (Oldname, NewName, Overwrite=false)

Rename or move a file or directory, no return, and its formal parameters are described as follows:

Oldname: Old directory or old file;

NewName: New directory or new file;

Overwrite: False if the new directory or new file already exists, it will be an error, otherwise the rename or move succeeds.

2-11) tf.gfile.Stat (filename)

Returns the statistics for the catalog, which returns the Filestatistics data structure, with DIR (tf.gfile.Stat (filename)) Retrieving the properties of the returned data as follows:

2-12) Tf.gfile.Walk (top, In_order=true)

Recursively gets the directory information generator, top is the directory name, In_order defaults to True to indicate the sequential traversal of the directory, otherwise it will be unordered traversal, each generation returns the following format information (dirname, [Subdirname, Subdirname, ...], [filename , filename, ...]).

2-13) tf.gfile.GFile (filename, mode)

Gets the text manipulation handle, similar to the text operation provided by Python, the Open () function, where filename is the name of the file to open, and how mode is read and written, and a text manipulation handle is returned.

Tf.gfile.Open () is the same name of the interface and can be used arbitrarily!

2-14) tf.gfile.FastGFile (filename, mode)

The difference between this function and Tf.gfile.GFile is simply "no blocking", which means that the function will get a handle to the text manipulation in a faster way.

Tf.gfile () function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.