Tôi đang gặp khó khăn khi tạo một thư mục và sau đó mở/tạo/ghi vào một tệp trong thư mục được chỉ định. Lý do có vẻ không rõ ràng với tôi. Tôi đang sử dụng os.mkdir [] và
path=chap_name
print "Path : "+chap_path #For debugging purposes
if not os.path.exists[path]:
os.mkdir[path]
temp_file=open[path+'/'+img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
Tôi nhận được lỗi
OSError: [Errno 2] No such file or directory: 'Some Path Name'
Đường dẫn là hình thức 'tên thư mục có không gian không được tìm thấy'
Tôi làm gì sai ở đây?
Cập nhật: Tôi đã thử chạy mã mà không tạo thư mục
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
Vẫn gặp lỗi. Bối rối hơn nữa.
Cập nhật 2: Vấn đề dường như là IMG_ALT, nó chứa '/' trong một số trường hợp, điều này gây ra rắc rối.
Vì vậy, tôi cần xử lý '/'. Có cách nào để thoát khỏi '/' hoặc xóa là tùy chọn duy nhất không?
Directory 'GeeksforGeeks' created Directory 'Geeks' created9
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Traceback [most recent call last]: File "gfg.py", line 18, in os.mkdir[path] FileExistsError: [WinError 183] Cannot create a file when that file / /already exists: 'D:/Pycharm projects/GeeksForGeeks'1
Ví dụ #2:
- os.mkdir[]
- os.makedirs[]
Ví dụ #3: Xử lý lỗi trong khi sử dụng phương thức Os.MakedIrs [].
OSError: [Errno 2] No such file or directory: 'Some Path Name'6
OSError: [Errno 2] No such file or directory: 'Some Path Name'0
Cú pháp: os.mkdir [đường dẫn, mode = 0o777, *, dir_fd = none] os.mkdir[path, mode = 0o777, *, dir_fd = None]
Tham số: Đường dẫn: Một đối tượng giống như đường dẫn biểu thị đường dẫn hệ thống tệp. Một đối tượng giống như đường dẫn là một chuỗi hoặc đối tượng byte biểu thị một đường dẫn.mode [tùy chọn]: Giá trị số nguyên biểu thị chế độ của thư mục sẽ được tạo. Nếu tham số này bị bỏ qua thì giá trị mặc định OO777 được sử dụng.DIR_FD [Tùy chọn]: Một mô tả tệp đề cập đến một thư mục. Giá trị mặc định của tham số này là không có. Nếu đường dẫn được chỉ định là tuyệt đối thì dir_fd bị bỏ qua.
path: A path-like object representing a file system path. A path-like object is either a string or bytes object representing a path.
mode [optional]: A Integer value representing mode of the directory to be created. If this parameter is omitted then default value Oo777 is used.
dir_fd [optional]: A file descriptor referring to a directory. The default value of this parameter is None.
If the specified path is absolute then dir_fd is ignored.Lưu ý: Danh sách tham số ‘*trong danh sách tham số chỉ ra rằng tất cả các tham số sau [ở đây trong trường hợp của chúng tôi‘ DIR_FD,] là các tham số chỉ dành cho từ khóa và chúng có thể được cung cấp bằng tên của chúng, không phải là tham số vị trí. The ‘*’ in parameter list indicates that all following parameters [Here in our case ‘dir_fd’] are keyword-only parameters and they can be provided using their name, not as positional parameter.
Loại trả về: Phương thức này không trả về bất kỳ giá trị nào. This method does not return any value.
Ví dụ #1: Sử dụng phương thức OSError: [Errno 2] No such file or directory: 'Some Path Name'
3 để tạo thư mục/tệp Use of
OSError: [Errno 2] No such file or directory: 'Some Path Name'3 method to create directory/file
OSError: [Errno 2] No such file or directory: 'Some Path Name'6
OSError: [Errno 2] No such file or directory: 'Some Path Name'0
OSError: [Errno 2] No such file or directory: 'Some Path Name'8
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
0path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
1OSError: [Errno 2] No such file or directory: 'Some Path Name'9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
3path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
4OSError: [Errno 2] No such file or directory: 'Some Path Name'9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
6path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
7path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
8path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
9Directory 'GeeksforGeeks' created Directory 'Geeks' created0
Directory 'GeeksforGeeks' created Directory 'Geeks' created1
Directory 'GeeksforGeeks' created Directory 'Geeks' created2
OSError: [Errno 2] No such file or directory: 'Some Path Name'8
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Directory 'GeeksforGeeks' created Directory 'Geeks' created5
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
1OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Directory 'GeeksforGeeks' created Directory 'Geeks' created8
Directory 'GeeksforGeeks' created Directory 'Geeks' created9
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Traceback [most recent call last]: File "gfg.py", line 18, in os.mkdir[path] FileExistsError: [WinError 183] Cannot create a file when that file / /already exists: 'D:/Pycharm projects/GeeksForGeeks'1
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
4OSError: [Errno 2] No such file or directory: 'Some Path Name'9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
6Traceback [most recent call last]: File "gfg.py", line 18, in os.mkdir[path] FileExistsError: [WinError 183] Cannot create a file when that file / /already exists: 'D:/Pycharm projects/GeeksForGeeks'5
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
8path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
9Directory 'GeeksforGeeks' created Directory 'Geeks' created0
Directory 'GeeksforGeeks' created Directory 'Geeks' created1
Directory 'GeeksforGeeks' created Directory 'Geeks' created2
Output:
Directory 'GeeksforGeeks' created Directory 'Geeks' created
OSError: [Errno 2] No such file or directory: 'Some Path Name'
8OSError: [Errno 2] No such file or directory: 'Some Path Name'
9 Directory 'GeeksforGeeks' created
Directory 'Geeks' created
5 Errors while using
OSError: [Errno 2] No such file or directory: 'Some Path Name'3 method.
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
1OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Directory 'GeeksforGeeks' created Directory 'Geeks' created8
Directory 'GeeksforGeeks' created Directory 'Geeks' created9
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Traceback [most recent call last]: File "gfg.py", line 18, in os.mkdir[path] FileExistsError: [WinError 183] Cannot create a file when that file / /already exists: 'D:/Pycharm projects/GeeksForGeeks'1
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
1OSError: [Errno 2] No such file or directory: 'Some Path Name'9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
3path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
4OSError: [Errno 2] No such file or directory: 'Some Path Name'9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
6D:/Pycharm projects/GeeksForGeeks/Authors/Nikhil3
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
8path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
9Directory 'GeeksforGeeks' created Directory 'Geeks' created0
Directory 'GeeksforGeeks' created Directory 'Geeks' created1
Directory 'GeeksforGeeks' created Directory 'Geeks' created2
Output:
Traceback [most recent call last]: File "gfg.py", line 18, in os.mkdir[path] FileExistsError: [WinError 183] Cannot create a file when that file / /already exists: 'D:/Pycharm projects/GeeksForGeeks'
OSError: [Errno 2] No such file or directory: 'Some Path Name'
8OSError: [Errno 2] No such file or directory: 'Some Path Name'
9 Directory 'GeeksforGeeks' created
Directory 'Geeks' created
5 Handling error while using
OSError: [Errno 2] No such file or directory: 'Some Path Name'3 method.
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
1OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Directory 'GeeksforGeeks' created Directory 'Geeks' created8
Directory 'GeeksforGeeks' created Directory 'Geeks' created9
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Traceback [most recent call last]: File "gfg.py", line 18, in os.mkdir[path] FileExistsError: [WinError 183] Cannot create a file when that file / /already exists: 'D:/Pycharm projects/GeeksForGeeks'1
Directory 'Nikhil' created Directory 'c' created5
Directory 'Nikhil' created Directory 'c' created6
Directory 'Nikhil' created Directory 'c' created7
D:/Pycharm projects/GeeksForGeeks/Authors/Nikhil3
Ví dụ #2: Lỗi trong khi sử dụng phương thức
OSError: [Errno 2] No such file or directory: 'Some Path Name'3.
Directory 'Nikhil' created Directory 'c' created7
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
8Traceback [most recent call last]: File "gfg.py", line 22, in os.makedirs[path] File "C:\Users\Nikhil Aggarwal\AppData\Local\Programs\Python/ / \Python38-32\lib\os.py", line 221, in makedirs mkdir[name, mode] FileExistsError: [WinError 183] Cannot create a file when that/ / file already exists: 'D:/Pycharm projects/GeeksForGeeks/Authors\\Nikhil'3
Output:
[WinError 183] Cannot create a file when that file/ /already exists: 'D:/Pycharm projects/GeeksForGeeks'
OSError: [Errno 2] No such file or directory: 'Some Path Name'
6 [WinError 183] Cannot create a file when that file/
/already exists: 'D:/Pycharm projects/GeeksForGeeks'
3
OSError: [Errno 2] No such file or directory: 'Some Path Name'8
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
[WinError 183] Cannot create a file when that file/ /already exists: 'D:/Pycharm projects/GeeksForGeeks'6
For example, consider the following path:
D:/Pycharm projects/GeeksForGeeks/Authors/Nikhil
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
4OSError: [Errno 2] No such file or directory: 'Some Path Name'9
D:/Pycharm projects/GeeksForGeeks/Authors/Nikhil2
8path=chap_name print "Path : "+chap_path #For debugging purposes temp_file=open[img_alt+'.jpg','w'] temp_file.write[buff] temp_file.close[] print " ... Done"
9path=chap_name print "Path : "+chap_path #For debugging purposes temp_file=open[img_alt+'.jpg','w'] temp_file.write[buff] temp_file.close[] print " ... Done"
Directory 'GeeksforGeeks' created Directory 'Geeks' created0Directory 'GeeksforGeeks' created Directory 'Geeks' created1D:/Pycharm projects/GeeksForGeeks/Authors/Nikhil8 os.makedirs[path, mode = 0o777, exist_ok = False]Ví dụ #3: Lỗi xử lý trong khi sử dụng phương thức
OSError: [Errno 2] No such file or directory: 'Some Path Name'3.
path: A path-like object representing a file system path. A path-like object is either a string or bytes object representing a path.
mode [optional]: A Integer value representing mode of the newly created directory. If this parameter is omitted then the default value Oo777 is used.
exist_ok [optional]: A default value False is used for this parameter. If the target directory already exists an OSError is raised if its value is False otherwise not.Loại trả về: Phương thức này không trả về bất kỳ giá trị nào. This method does not return any value.
Ví dụ #1: Sử dụng phương thức OSError: [Errno 2] No such file or directory: 'Some Path Name'
3 để tạo thư mục/tệp Use of
Traceback [most recent call last]: File "gfg.py", line 22, in os.makedirs[path] File "C:\Users\Nikhil Aggarwal\AppData\Local\Programs\Python/ / \Python38-32\lib\os.py", line 221, in makedirs mkdir[name, mode] FileExistsError: [WinError 183] Cannot create a file when that/ / file already exists: 'D:/Pycharm projects/GeeksForGeeks/Authors\\Nikhil'4 method to create directory.
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
1OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Directory 'GeeksforGeeks' created Directory 'Geeks' created8
Directory 'GeeksforGeeks' created Directory 'Geeks' created9
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Traceback [most recent call last]: File "gfg.py", line 18, in os.mkdir[path] FileExistsError: [WinError 183] Cannot create a file when that file / /already exists: 'D:/Pycharm projects/GeeksForGeeks'1
Ví dụ #2: Lỗi trong khi sử dụng phương thức
OSError: [Errno 2] No such file or directory: 'Some Path Name'3.
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
4OSError: [Errno 2] No such file or directory: 'Some Path Name'9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
6Directory 'Nikhil' created successfully9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
8path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
9Directory 'GeeksforGeeks' created Directory 'Geeks' created0
Directory 'GeeksforGeeks' created Directory 'Geeks' created1
Directory 'GeeksforGeeks' created Directory 'Geeks' created2
OSError: [Errno 2] No such file or directory: 'Some Path Name'8
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Directory 'GeeksforGeeks' created Directory 'Geeks' created5
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
1OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Directory 'GeeksforGeeks' created Directory 'Geeks' created8
Directory 'GeeksforGeeks' created Directory 'Geeks' created9
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Traceback [most recent call last]: File "gfg.py", line 18, in os.mkdir[path] FileExistsError: [WinError 183] Cannot create a file when that file / /already exists: 'D:/Pycharm projects/GeeksForGeeks'1
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
4OSError: [Errno 2] No such file or directory: 'Some Path Name'9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
6OSError: [Errno 2] No such file or directory: 'Some Path Name'17
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
8path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
9Directory 'GeeksforGeeks' created Directory 'Geeks' created0
Directory 'GeeksforGeeks' created Directory 'Geeks' created1
Directory 'GeeksforGeeks' created Directory 'Geeks' created2
Output:
Directory 'Nikhil' created Directory 'c' created
OSError: [Errno 2] No such file or directory: 'Some Path Name'
8OSError: [Errno 2] No such file or directory: 'Some Path Name'
9 Directory 'GeeksforGeeks' created
Directory 'Geeks' created
5
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
1OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Directory 'GeeksforGeeks' created Directory 'Geeks' created8
Directory 'GeeksforGeeks' created Directory 'Geeks' created9
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Traceback [most recent call last]: File "gfg.py", line 18, in os.mkdir[path] FileExistsError: [WinError 183] Cannot create a file when that file / /already exists: 'D:/Pycharm projects/GeeksForGeeks'1
Ví dụ #2: Lỗi trong khi sử dụng phương thức
OSError: [Errno 2] No such file or directory: 'Some Path Name'3.
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
4OSError: [Errno 2] No such file or directory: 'Some Path Name'9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
6Directory 'Nikhil' created successfully9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
8path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
9Directory 'GeeksforGeeks' created Directory 'Geeks' created0
Directory 'GeeksforGeeks' created Directory 'Geeks' created1
Directory 'GeeksforGeeks' created Directory 'Geeks' created2
Output:
Traceback [most recent call last]: File "gfg.py", line 22, in os.makedirs[path] File "C:\Users\Nikhil Aggarwal\AppData\Local\Programs\Python/ / \Python38-32\lib\os.py", line 221, in makedirs mkdir[name, mode] FileExistsError: [WinError 183] Cannot create a file when that/ / file already exists: 'D:/Pycharm projects/GeeksForGeeks/Authors\\Nikhil'
OSError: [Errno 2] No such file or directory: 'Some Path Name'
8OSError: [Errno 2] No such file or directory: 'Some Path Name'
9 Directory 'GeeksforGeeks' created
Directory 'Geeks' created
5 Handling errors while using os.makedirs[] method.
OSError: [Errno 2] No such file or directory: 'Some Path Name'6
OSError: [Errno 2] No such file or directory: 'Some Path Name'0
Directory 'GeeksforGeeks' created Directory 'Geeks' created9
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Traceback [most recent call last]: File "gfg.py", line 18, in os.mkdir[path] FileExistsError: [WinError 183] Cannot create a file when that file / /already exists: 'D:/Pycharm projects/GeeksForGeeks'1
Ví dụ #2: Lỗi trong khi sử dụng phương thức
OSError: [Errno 2] No such file or directory: 'Some Path Name'3.
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
4OSError: [Errno 2] No such file or directory: 'Some Path Name'9
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
6Directory 'Nikhil' created Directory 'c' created5
OSError: [Errno 2] No such file or directory: 'Some Path Name'52
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
8path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
9Directory 'GeeksforGeeks' created Directory 'Geeks' created0
Directory 'GeeksforGeeks' created Directory 'Geeks' created1
Directory 'GeeksforGeeks' created Directory 'Geeks' created2
OSError: [Errno 2] No such file or directory: 'Some Path Name'8
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Directory 'GeeksforGeeks' created Directory 'Geeks' created5
path=chap_name
print "Path : "+chap_path #For debugging purposes
temp_file=open[img_alt+'.jpg','w']
temp_file.write[buff]
temp_file.close[]
print " ... Done"
1OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Directory 'GeeksforGeeks' created Directory 'Geeks' created8
Directory 'GeeksforGeeks' created Directory 'Geeks' created9
OSError: [Errno 2] No such file or directory: 'Some Path Name'9
Traceback [most recent call last]: File "gfg.py", line 18, in os.mkdir[path] FileExistsError: [WinError 183] Cannot create a file when that file / /already exists: 'D:/Pycharm projects/GeeksForGeeks'1
Output:
Directory 'Nikhil' created successfully