Coucou,
Soit un fichier téléchargé, renommé et chmodé via ce code:
Dans ce fichier xml, j'aimerais remplacer les caractères "&" par "&"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 #!/usr/bin/python # -*- coding: utf-8 -*- import urllib,os the_location="/home/toto/xmlfiles/" urllib.urlcleanup() url="http://www.toto.fr/fichier.xml" dest=the_location + "toto.xml" monurl = urllib.urlretrieve(url,dest) os.chmod(dest,0777)
j'ai donc essayé:
mais j'ai une erreur de syntaxe. qu'es-ce que j'ai râté?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 #!/usr/bin/python # -*- coding: utf-8 -*- import urllib,os import replace the_location="/home/toto/xmlfiles/" urllib.urlcleanup() url="http://www.toto.fr/fichier.xml" dest=the_location + "toto.xml" monurl = urllib.urlretrieve(url,dest) os.chmod(dest,0777) >>>'&'.replace('c','amp;',2) '&'
++
Partager