os.makedirs和os.mkdir 生成文件夹
os.makedirs('./2') 将生成名为2的文件夹 使用os.mkdir時,如果你給定的 path 參數是個多層的 path,如果某個中繼的目錄不存在(比如說上例中的foo), Python 將會報錯. 但如果使用os.makedirs則 Python 會連同中間的目錄一起建立.但有一點值得注意,當 path 末端的目錄已經存在的話,os.makedirs也是會引發例外. makedirs(name, mode=511, exist_ok=False) makedirs(name [, mode=0o777][, exist_ok=False]) Super-mkdir; create a leaf directory and all intermediate ones. Works like mkdir, except that any intermediate path segment (not just the rightmost) will be created if it does not exist. If the target director...