Created
June 5, 2014 13:49
-
-
Save neriberto/1f1533e8578ed595e86e to your computer and use it in GitHub Desktop.
Descobre o maior caminho no sistema operacional
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
sizepath = 0; | |
longpath = None; | |
def calc(path): | |
global longpath | |
global sizepath | |
length = len(path) | |
if length > sizepath: | |
sizepath = length | |
longpath = path | |
def walk(path): | |
for dirname, dirnames, filenames in os.walk(path): | |
for subdirname in dirnames: | |
calc(os.path.join(dirname, subdirname)) | |
for filename in filenames: | |
calc(os.path.join(dirname, filename)) | |
walkin = "C:\\" | |
walk(walkin) | |
print "O caminho maior encontrado foi de %s caracteres" % sizepath | |
print "O caminho : %s" % longpath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment