pycharm出现Type Error

直接放代码:

for files,filepath,folders in os.walk(path):
    for file in files:
        size = os.path.getsize(os.path.join(filepath, file)) / 1024 / 1024  # 1024b=1kb 1024kb=1MB 1024MB=1GB
        os.remove(os.path.join(filepath,file))
Traceback (most recent call last):
  File "C:/Users/Administrator/Desktop/python.py", line 22, in <module>
    size = os.path.getsize(os.path.join(filepath, file)) / 1024 / 1024  # 1024b=1kb 1024kb=1MB 1024MB=1GB
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\ntpath.py", line 76, in join
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not list

 

for files,filepath,folders in os.walk(path):


    for file in folders:


        size = os.path.getsize(os.path.join(files, file)) / 1024 / 1024  # 1024b=1kb 1024kb=1MB 1024MB=1GB


        os.remove(os.path.join(files, file))