SHOW:
|
|
- or go back to the newest paste.
| 1 | - | PS E:\> python pythonscript1 |
| 1 | + | import os |
| 2 | - | C:\Users\Owner\AppData\Local\Programs\Python\Python36\python.exe: can't open file 'pythonscript1': [Errno 2] No such file or directory |
| 2 | + | def get_size(start_path = '.'): |
| 3 | - | PS E:\> python pythonscript1.py |
| 3 | + | total_size = 0 |
| 4 | - | File "pythonscript1.py", line 10 |
| 4 | + | for dirpath, dirnames, filenames in os.walk(start_path): |
| 5 | - | print get_size() |
| 5 | + | for f in filenames: |
| 6 | - | ^ |
| 6 | + | fp = os.path.join(dirpath, f) |
| 7 | - | SyntaxError: invalid syntax |
| 7 | + | total_size += os.path.getsize(fp) |
| 8 | - | PS E:\> |
| 8 | + | return total_size |
| 9 | ||
| 10 | print get_size() |