How can I find a specific file using python? -


i new service if make mistake please tell me.

i new python , have ideas on projects want start. 1 of these projects includes process of looking in file in specific folder , being able write, read or delete it.

i want make program allows user enter password , able access, print screen, create, edit, delete text files. said text files contain information such passwords or profiles of people or dirarie entered. able print, delete , edit files need program able match , locate file within specific folder file (file name) user inputed. folder in question folder actual program saved in because default location saved , @ level that's can do/program @ minute.

i using version 3.5.2 of python , grateful if me problem...

sincerely isaac,

to start things off, i'm going assume have basic required knowledge of python. , i'd preface answer recommending @ least try , google before asking on stackoverflow.

that being said, following excellent resource accomplish: https://www.tutorialspoint.com/python/python_files_io.htm

as stated in resource i've linked, open file need know path of file access.

lets path of text file c:\users\user\sampletext.txt

for simplicity, associate required path variable:

path = 'c:\users\user\sampletext.txt' 

to open file need use python's built in open function. function takes 2 parameters, file access , mode access in. can read more access modes in resource have linked.

since want to read , write mode should specify r+.

file = open(path, 'r+') 

if want remove file, @ top of script need import os library.

import os 

to delete said file use file path specified:

os.remove(path) 

again, want reiterate resources these easy find , beneficial learning if try , find these on own first. isn't hard.

good luck project.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -