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

  • Carlos Delgado

    Carlos Delga

    21 HAZİRAN 2011
  • inovationgmbh

    inovationgmb

    28 EYLÜL 2010
  • Press Start

    Press Start

    4 HAZİRAN 2006