Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2443 connectés 

  FORUM HardWare.fr
  Programmation
  Python

  [PYTHON] Comment faire pour supprimer un fichier ?

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[PYTHON] Comment faire pour supprimer un fichier ?

n°636041
Noren2
Posté le 09-02-2004 à 14:49:30  profilanswer
 

Salut,  
 
Bon je sais créer un fichier, l'ouvrir, le lire, ecrire... Mais comment fait on pour supprimer un fichier ??  
 
Merci d'avance

mood
Publicité
Posté le 09-02-2004 à 14:49:30  profilanswer
 

n°636058
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 09-02-2004 à 15:02:31  profilanswer
 

Je précise : je ne connais rien à Python, tu en sais certainement plus que moi. Par contre, quand je suis confronté à un souci, je cherche et ensuite je pose une question !
 
Un petit effort de recherche t'aurait permis de trouver la page suivante :
http://www.python.org/doc/current/lib/os-file-dir.html
Et ainsi de connaitre la méthode suivante :

Citation :


remove( path)  
 
Remove the file path. If path is a directory, OSError is raised; see rmdir() below to remove a directory. This is identical to the unlink() function documented below. On Windows, attempting to remove a file that is in use causes an exception to be raised; on Unix, the directory entry is removed but the storage allocated to the file is not made available until the original file is no longer in use. Availability: Macintosh, Unix, Windows.  


 
Faites un petit effort de recherche enfin...:sarcastic:


---------------
J'ai un string dans l'array (Paris Hilton)
n°636061
Noren2
Posté le 09-02-2004 à 15:04:49  profilanswer
 

wé j'ai trouvé :)  
 
Merci pour cette reponse rapide en tout cas :)
 

Code :
  1. import os
  2. def test(login,pwd,hostftp=hostftp):
  3.       message=open('testsupp.txt','w')
  4.       message.close()
  5.       os.remove('testsupp.txt')
  6.       return "ok"


Message édité par Noren2 le 09-02-2004 à 15:06:50
n°636100
chaica
Posté le 09-02-2004 à 15:46:31  profilanswer
 

Be gorgeous, use python.

n°636156
Taz
bisounours-codeur
Posté le 09-02-2004 à 16:27:01  profilanswer
 

chaica a écrit :

life is short, use python.

n°636159
chaica
Posté le 09-02-2004 à 16:29:54  profilanswer
 


Ouais mais ça c'est l'officiel, l'autre c'est le mien :sol:


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Python

  [PYTHON] Comment faire pour supprimer un fichier ?

 

Sujets relatifs
[XMI] Comment récupérer un fichier [URGENT ][RECH] Jeux de pong programmé en Python
peut - on creer une variable dans le fichier bash ?Appel vers un fichier JS externe qui ne marche pas.
Corriger un fichier html[D4] Un fichier que deletefile() n'efface pas. Pourquoi ?
[PHP] Un commande pour rapatrier un fichierproblème d'antislash à la création d'un fichier via un fichier php
avec kel programme editer un fichier php ?Programation d'un petit jeu en python
Plus de sujets relatifs à : [PYTHON] Comment faire pour supprimer un fichier ?


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR