SORU
19 Ocak 2012, PERŞEMBE


Nasıl dizin Python içinde olup olmadığını bulmak için

Python os Bu modül, bir yolu var, eğer bir dizin olup olmadığını bulmak için, bir şey gibi

>>> os.direxists(os.path.join(os.getcwd()), 'new_folder')) # in pseudocode
True/False

CEVAP
19 Ocak 2012, PERŞEMBE


Eğer bir dosya veya dizin olup olmadığı umurunda bile os.path.isdir os.path.exists arıyoruz.

Örnek:

import os
print(os.path.isdir("/home/el"))
print(os.path.exists("/home/el/myfile.txt"))

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • BlackBoxTV

    BlackBoxTV

    7 Mayıs 2007
  • efaustus9

    efaustus9

    16 HAZİRAN 2006
  • majesticdubstep

    majesticdubs

    3 Kasım 2011