简体   繁体   中英

how to make the script to start running from the top folder on windows

The location of this script is on D:
The script works for drives other than D:
On D: the script does not start from the top folder
It starts from the script working directory
How to make it start from the root?

  def folder_usage_one(folder):
        from pathlib import Path
        root = Path(folder)
        return (sum(f.stat().st_size 
                for f in root.glob('**/*') if f.is_file()))

Try using "D:\\" for referencing the root of the D drive instead of "D:"

More details on this similar Q&A : Why does pathlib.Path("C:") resolve to the working directory on Windows?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM