Python verifică dacă există un fișier

Exemple de cod

60
0

python verifică dacă există un fișier

import os

os.path.exists("file.txt") # Or folder, will return true or false
28
0

cum să verificați dacă fișierul există în python

import os.path

if os.path.isfile('filename.txt'):
    print ("File exist")
else:
    print ("File not exist")
11
0

python os dacă există fișier

import os.path

if os.path.isfile('filename.txt'):
    print ("File exist")
else:
    print ("File not exist")
10
0

python verifică dacă există un fișier

#using pathlib
from pathlib import Path

file_name = Path("file.txt")
if file_name.exists():
    print("exists") 
else:
    print("does not exist") 
8
0

fișier există python

import os.path

if os.path.exists('filename.txt'):
    print ("File exist")
else:
    print ("File not exist")
5
0

cum să verificați dacă fișierul există pyuthon

import os
file_exists = os.path.exists("example.txt") # Returns boolean representing whether or not the file exists

Pagini similare

Pagini similare cu exemple

În alte limbi

Această pagină este în alte limbi

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................