glob library manual

  golb module is used to find "Path + file name" filename named in line with specific rules, its function is to retrieve the path.

glob.glob

  Return path for a list of all matching files. It has only one argument pathname, file paths defined matching rules, there can be an absolute path, or a relative path. The following are examples of the use glob.glob:

input_path=glob.glob(r'docs/*.jpg')
print(input_path)

 The results:

  Our aim is to traverse all of the following paths jpg images in this folder, but it is the path the image above code: run \ yupeilun under \ pix2pix-tensorflow-master, so we use the glob.glob () in: E a relative path, the return path corresponding list is also a relative path.

 

  If we use absolute paths in glob.glob (), then return to the path of the list is the absolute path. And the two comparative examples can be seen clearly * is a placeholder for a value not specific.

 

 glob.iglob

  Gets a programmable calendar objects with which you can get the file path name that matches one by one. Distinguished glob.glob, and () is: glob.glob simultaneously acquire all of the matching path, but only once glob.iglob obtaining a matching path at the same time generating a return glob.iglob type. See the examples below:

 

Guess you like

Origin www.cnblogs.com/happy-sir/p/11531858.html