Absolute path:
Backslash'\': Since the backslash'\' is to be used as an escape character, if you want to use a backslash to represent a path, you must use a double backslash.
all_file_dir = 'F:\\pythonProject\\ResNet\\2020'
Original string r'': The original string + single backslash'\' can be used to represent the path
r'F:\pythonProject\ResNet\2020'
Slash'/': In order to avoid the trouble of the escape character'\' and the original string, you can use the slash'/' directly. Python recognizes that'/' is used as a path splitting symbol
all_file_dir = 'F:/pythonProject/ResNet/2020'
relative path:
./Images represents the Images folder in the current directory
…/Images means the Images folder in the upper directory of the current directory
/Images means the project root directory
note:
all_file_dir = 'F:/pythonProject/ResNet/2020'
train_image_dir = os.path.join(all_file_dir, "trainImageSet")
print(train_image_dir)
It seems that the python interpreter recognizes "\" after joining, but thinks that "\" cannot be used when writing an absolute path, and it will be treated as an escape character.