原始字符串(Raw String)是python中一类比较特殊的字符串,以大写字母R或小写字母r开始。
r'C:\Users\lenovo\Downloads\all\train'
在原始字符串中,字符'\'不再具有转义作用。
原始字符串是为正则表达式设计的。
也可以用来方便地表示Windows下的系统路径。但是,如果路径以"\"结尾,则会报错。
import os, shutil
# The path to the directory where the original
# dataset was uncompressed
original_dataset_dir = r'C:\Users\lenovo\Downloads\all\train'
# The directory where we will
# store our smaller dataset
base_dir = r'C:\Users\lenovo\Downloads\cats_and_dogs_small'
os.mkdir(base_dir)