Python file detection 📁

Ғылым және технология

Python file detection handling tutorial example explained
#python #file #handling
import os
path = "C:\\Users\\User\\Desktop\\test.txt"
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!")

Пікірлер: 70

  • @BroCodez
    @BroCodez3 жыл бұрын

    import os path = "C:\\Users\\User\\Desktop\\test.txt" 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!")

  • @StrangerDanger352

    @StrangerDanger352

    2 жыл бұрын

    it's not detecting bro help me

  • @irfanhakim4617

    @irfanhakim4617

    2 жыл бұрын

    @@StrangerDanger352 What ide you using? is it replit?

  • @StrangerDanger352

    @StrangerDanger352

    2 жыл бұрын

    @@irfanhakim4617 i am using pycharm it's detecting now😁

  • @irfanhakim4617

    @irfanhakim4617

    2 жыл бұрын

    @@StrangerDanger352 GREAT! HAPPY CODING!🎉

  • @StrangerDanger352

    @StrangerDanger352

    2 жыл бұрын

    @@irfanhakim4617 which ide do you use?

  • @tanatswamurwira3604
    @tanatswamurwira36042 жыл бұрын

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

  • @21pradaofficial4
    @21pradaofficial4 Жыл бұрын

    the only KZread channel that matters

  • @lw9954
    @lw9954 Жыл бұрын

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

  • @szymongrzebyk5948

    @szymongrzebyk5948

    2 ай бұрын

    True

  • @airlanggak5391
    @airlanggak53912 жыл бұрын

    appreciate your efforts man!

  • @knownrobloxian3381
    @knownrobloxian33812 жыл бұрын

    0:57 nuclear launch codes lol

  • @christinley5213
    @christinley52133 жыл бұрын

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

  • @Harsh-rs2kv
    @Harsh-rs2kv Жыл бұрын

    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)😉😉😉

  • @piotrkopcewicz5227
    @piotrkopcewicz52272 жыл бұрын

    Great tutorial !! :) Thx

  • @dayya4004
    @dayya40043 жыл бұрын

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

  • @kamranchaudhry6887
    @kamranchaudhry68875 ай бұрын

    Great tutorial!

  • @honeyd5550
    @honeyd5550 Жыл бұрын

    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!")

  • @spartanranger
    @spartanranger2 жыл бұрын

    Thanks for the video bro

  • @tarikyassa1076
    @tarikyassa10763 жыл бұрын

    Thanks bro!

  • @Cyberbully34
    @Cyberbully3411 ай бұрын

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

  • @kraxpan2618
    @kraxpan26182 жыл бұрын

    big thanks bro

  • @HussainAli-sb1dv
    @HussainAli-sb1dv8 ай бұрын

    love you bro

  • @DMcDonald14
    @DMcDonald142 жыл бұрын

    Solid!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @kemann3815
    @kemann38152 жыл бұрын

    Amazing

  • @jasonhammerle3582
    @jasonhammerle3582 Жыл бұрын

    Awesome

  • @beingzero7541
    @beingzero75412 жыл бұрын

    Wow!

  • @AnishSaha_
    @AnishSaha_3 жыл бұрын

    💖💖💖

  • @marjoriemyers9474
    @marjoriemyers9474Ай бұрын

    you saved me thanks

  • @uuhju7004
    @uuhju70043 жыл бұрын

    ty

  • @dilipmurmu7870
    @dilipmurmu78703 жыл бұрын

    Hey bro !! What's up

  • @nialyavuzturk379
    @nialyavuzturk3795 сағат бұрын

    thank you brotha

  • @detectivedoom5175
    @detectivedoom51752 жыл бұрын

    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...

  • @jcmkt9661

    @jcmkt9661

    2 жыл бұрын

    delete the ".txt" in the file name in your computer. try it

  • @rihabhassanha8200

    @rihabhassanha8200

    Жыл бұрын

    Same

  • @jarenventures

    @jarenventures

    Жыл бұрын

    @@jcmkt9661 how do i call a folder? just hitting folder didn't work

  • @J11_boohoo

    @J11_boohoo

    6 ай бұрын

    Same

  • @aijazbirsfun547
    @aijazbirsfun547Ай бұрын

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

  • @christopher2176
    @christopher217611 ай бұрын

    Nice nuclear launch codes 🤣

  • @bartekz88
    @bartekz883 жыл бұрын

    Your favourite game probably is Broforce.

  • @isuckatminecraft2179
    @isuckatminecraft217911 күн бұрын

    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.

  • @Owlrrex
    @Owlrrex2 жыл бұрын

    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?

  • @banglawarlock3947

    @banglawarlock3947

    Жыл бұрын

    maybe because when you copy a path its backslash by default. if you change them to normal slash, you nend to press backspace then enter a new slash which seems like so much more work than entering just one more backslash

  • @bestja9406
    @bestja9406 Жыл бұрын

    A Nuclear launch codes on his desktop?

  • @pbsmoothie7281
    @pbsmoothie7281 Жыл бұрын

    YT algorithm comment

  • @ayushkertshong7296
    @ayushkertshong72963 жыл бұрын

    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)

  • @techlace1195

    @techlace1195

    Жыл бұрын

    hey, i don't know if you still need answer but i wanna share how to solve this problem. choose the file and press command+i, then you;ll get info about your file copy the path as pathname. it'll be something like this: /Users/abcd/Documents/Photos/Efg. thenk just paste this path. hope i'll help smbd

  • @norbertjanovics5655
    @norbertjanovics56552 жыл бұрын

    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?

  • @hippopotamus_nr2587

    @hippopotamus_nr2587

    2 жыл бұрын

    did you print it? (probs yes but just to be sure)

  • @norbertjanovics5655

    @norbertjanovics5655

    2 жыл бұрын

    @@hippopotamus_nr2587 yea i did, well i made a new file in the same project, and this code works in the first file, but not in the new one... so i really dont know...

  • @hippopotamus_nr2587

    @hippopotamus_nr2587

    2 жыл бұрын

    @@norbertjanovics5655 then i don't get it, weird that it can run a file program for the first one, but not for the second. maybe it has to do with the type of file, but i don't know a lot about that sort of thing. hopefuly someone with more experience can come help you

  • @CarlosEduardo-nb4we

    @CarlosEduardo-nb4we

    2 жыл бұрын

    I have the same problem, did you solve it?

  • @hippopotamus_nr2587

    @hippopotamus_nr2587

    2 жыл бұрын

    @@CarlosEduardo-nb4we i didn't, no

  • @followmePeeps
    @followmePeeps6 ай бұрын

    nuclear launch codes 😆

  • @josephadelakun
    @josephadelakun Жыл бұрын

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

  • @secretr5024
    @secretr5024 Жыл бұрын

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

  • @oreoplushie6231

    @oreoplushie6231

    11 ай бұрын

    because the variable is the one telling the program which file to look for.

  • @Algeriawindows69

    @Algeriawindows69

    8 ай бұрын

    it tells it where is the file

  • @MissKrake
    @MissKrake Жыл бұрын

    🛋😌🤓

  • @orfredymelobeltran5237
    @orfredymelobeltran52372 жыл бұрын

    Bro

  • @techlace1195
    @techlace1195 Жыл бұрын

  • @aijazbirsfun547
    @aijazbirsfun547Ай бұрын

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

  • @aijazbirsfun547
    @aijazbirsfun547Ай бұрын

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

  • @aijazbirsfun547
    @aijazbirsfun547Ай бұрын

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

Келесі