Python:检查CVS存储库中的目录

时间:2014-06-11 15:56:50

标签: python repository cvs directory-structure

我想知道我是否可以使用

os.path.isdir(sourceDirectory)

检查CVS存储库中是否存在目录。同样,如果os.walk方法适用于存储库目录。如果没有,那么解决这个问题的好方法是什么?

1 个答案:

答案 0 :(得分:0)

os已经很好地处理了这个!难道蟒蛇没精彩? 以下示例在计算机的根目录中搜索名为CSV的文件,但您可以将其指向您喜欢的任何目录,包括相对路径。

def file_exists():
   path = '/' # the path you want to search for the file in
   target = 'CSV' # name of the directory
   if target in os.list:
      #do whatever you were going to do once you confirmed that this file exists
      return True
   return False