Python file detection 📁

preview_player
Показать описание
Python file detection handling tutorial example explained

#python #file #handling

import os

print("That location exists!")
print("That is a file")
print("That is a directory!")
else:
print("That location doesn't exist!")
Рекомендации по теме
Комментарии
Автор

import os

path =

if os.path.exists(path):
print("That location exists!")
if os.path.isfile(path):
print("That is a file")
elif os.path.isdir(path):
print("That is a directory")
else:
print("That location doesn't exist!")

BroCodez
Автор

This just gave me ideas for file management and sorting on my pc. Thank you Bro Code!

tanatswamurwira
Автор

Bro gonna ignore the fact he has a "nuclear launch codes" folder..

lw
Автор

i want that Nuclear launch code😈..
just kiddin..im loving every minute of your videos

dayya
Автор

thanks for teaching python in this easy method
I wish i could meet you for once
you are a legend bro(or whatever your REAL name is)😉😉😉

Harsh-rskv
Автор

Why does this guy have the nuclear launch codes on his desktop 💀 💀 💀

Cyberbully
Автор

I really liked this! But just so I didnt have to change the path manually I changed the path variable to path = input("What is the path!: "),
Ik it does the same thing but I just thought I would say that


line of code:



import os

path = input("What is the path!: ")

if os.path.exists(path):
print("That location exist!")
if os.path.isfile(path):
print("This is a file!")

honeyd
Автор

See u dropping sum vids here..thank you!!:) keep em coming buddy!! Wrkn through new java tutorial now...teach me yoda!!!

christinley
Автор

So, I made the text file on desktop, and copied the location as highlighted in the video, however for some reason it says the location doesn't exist, which is odd...

detectivedoom
Автор

Hi there does this code work differently for different versions of windows as mine say's that it could not detect a file even though I created one and copied it exactly into my code.

isuckatminecraft
Автор

Your favourite game probably is Broforce.

bartekz
Автор

Radhe Radhe
Sanatan Hi Satya Hai
Jai To All Gods & Godesses
Jai Baba Farid Ji
Radhaswami Ji

aijazbirsfun
Автор

A Nuclear launch codes on his desktop?

bestja
Автор

Hey Bro, quick question: Was there a specific reason you didn't mention raw string literals (r"This/Is/MyPath") to avoid escaping every single slash?

Owlrrex
Автор

Hello there, its not working for me, it has no any "exists" or "not exists" i made the file in different directories and still nothing, the program run blank with a "Process finished with exit code 0" and nothing happens. Any suggestions?

norbertjanovics
Автор

Can we know if a file exist when we don't know the file location path??!

josephadelakun
Автор

I'm using a Mac and I'm having problems to detect files and folders both:
import os
a="Macintosh HD⁩ ▸ ⁨Users⁩ ▸ ⁨ayushtshong⁩ ▸ ⁨Desktop"
if os.path.exists(a):
print("the file exists")
else:
print("it doesn't)

ayushkertshong
Автор

Yo bro code, if i dont use path as my variable the program dies why is that?

secretr