Open/Close Read/Write/Add input


In [31]:
def writing():
    """ Create a new file if necessary and write in it by input"""

    print("Nom du fichier :")
    filename=input()
    f = open(filename, 'a')
    f.close()
    print("Nouvelles lignes de commandes ? O/N ?")
    a = input()
    while a == "O" :
        print("Ecrire les nouvelles lignes de commandes :")
        with open(filename, 'a') as f:
            f.write(input())
            print("Nouvelles lignes de commandes ? O/N ?")
            a = input()
    print("Affichage du contenu du fichier :")
    with open(filename, 'r') as f:
        print(f.read())