“Файл существует Python” Ответ

Проверьте, существует ли файл

import os

os.path.exists("file.txt") # Or folder, will return true or false
Duco Defiant Dogfish

Как проверить, существует ли файл в Python

import os.path

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

ОС Python, если файл существует

import os.path

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

Файл существует Python

import os.path

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

Проверьте, существует ли файл

#using pathlib
from pathlib import Path

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

Как проверить, существует ли файл pyuthon

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

Ответы похожие на “Файл существует Python”

Вопросы похожие на “Файл существует Python”

Больше похожих ответов на “Файл существует Python” по Python

Смотреть популярные ответы по языку

Смотреть другие языки программирования