vendredi 22 novembre 2019

Finding files in python3

1.) I am trying to search for a file "hello.py", and return the string in python 3 The file path is "/Users/Joshua/Appdata/Local/Programs/Python/Python38/User_code/Hello.py" but instead the code returns tons of: { print("file not here") }

2.)I can't run hello.py atm, cause idk - (1)im not in right directory (2)idk if its module/or script (3)first time in python and im new to it.

3.) how should i have set up python to cause less headache??? should i have installed it to "/Users/Joshua/ >>>>" to cause less headache ?? how did you make it easier for you to learn?

PS: first question im asking on stack overflow...Hooray

import os
File = 'hello.py'
for root, dirs, files in os.walk('/Users/Joshua/Appdata/Local/Programs/Python/Python38/'):  
    if File in files:
        print ("File exists")
    if File not in files:
        print("file not here")

Aucun commentaire:

Enregistrer un commentaire