def print_file(dir, file):
    path = Path(dir + '/' + file)
    if path.exists():
        try:
            with path.open('r') as fd:
                print(fd.read())
        except IOError as err:
            print(err)
def create_file(dirname):
    file_name = "mafile.txt"
    file_path = Path(dirname + '/' + file_name)
    try:
        fd = file_path.open('w+')
        fd.write("This is the most useless file you have ever seen...")
        fd.close()
    except IOError as err:
        print(err)
    return file_name
Example #3
0
#!/usr/bin/python3
# coding : utf8

from local_lib.path import Path

if __name__ == '__main__':
	d = Path('/tmp/djangod03')
	d.mkdir_p()
	f = Path('/tmp/djangod03/bidon.txt')
	f.touch()
	f.open()
	f.write_text("Coucou\n", append=True)
	print(f.text())
Example #4
0
def EcrireLireAfficher():
	f = Path('/Users/xmillero/python/d03/D03/ex01/dossier/fichier')
	f.open()
	f.write_text("Comme vous pouvez le constater,\nJ'ai réussi l'exercice !\nMais avant de me donner tous les points, il faut vérifier qu'il y a bien la version de pip, le fichier log, la local_lib, le dossier et le fichier dedans avec ce message...")
	
	print(f.text()) 
Example #5
0
from local_lib.path import Path

if __name__ == '__main__':
	folder = Path('./forex01')
	folder.mkdir_p()
	file = Path('./forex01/forex01.txt')
	file.touch()
	file.open()
	file.write_text("For ex01 text")
	print(file.text())