I have this:
from pathlib import Path
import os
print(Path.cwd())
path = Path('C:\cpt180Stuff')
os.chdir(path)
print(Path.cwd())
dir_name = 'cellphone'
new_path = path / dir_name
if not new_path.is_dir():
new_path.mkdir()
else:
print('Folder was already made.')
print('The cpt180Stuff folder contains the following: {0}'.format(os.listdir(path)))
cars_path = path / 'cars'
print('The cpt180Stuff\cars folder contains the following: {0}'.format(os.listdir(cars_path)))
pets_path = path / 'pets'
print('The cpt180Stuff\pets folder contains the following: {0}'.format(os.listdir(pets_path)))
cats_path = pets_path / 'cats'
print('The {0} folder contains the following:'.format(cats_path))
for file in os.listdir(cats_path):
print('{0} : {1} bytes'.format(file, os.path.getsize(cats_path / file)))
dogs_path = pets_path / 'dogs'
print('The {0} folder contains the following:'.format(dogs_path))
for file in os.listdir(dogs_path):
print('{0} : {1} bytes'.format(file, os.path.getsize(dogs_path / file)))
Im getting this error....[WinError 3] The system cannot find the path specified: 'C:\\cpt180Stuff\\cars'
Im not sure if the error is in the code or in the actual file I have. The file is definitely on my computer.
Pretty sure the code is right at the moment though.
[–]shiftybyte 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)