bonjour
voila c'est un peu difficile a expliquer
j' ai fonction python qui me renvoie des donnees dans un fichier html
points1 = [(<Material: CV66>, 7.949825327404338), (<Material: Al2O3>, 5.3037079262845355), (<Material: CN56>, 6.1803499982835977)]
je separe ensuite ces donnees
{% for x, y in points1 %}
<td width="100" style="text-align:center"><TT><span>{{ x }} : {{ y|floatformat:2}}%</span></TT></td>
{% endfor %}
et j'obtiens
CV66 : 7.95% Al2O3 : 5.30% CN56 : 6.18%
le probleme est que si je veux envoyer points1 vers un autre fichier html
les choses se compliquent
j'envoie points1 via un formulaire
<form action="...
<td><input type="text" style= "display:none;" value= "{{ points1 }}" name="pt1" size="8" maxlength="5" </td>
</form>
evidemment je recupere points1
[(<Material: CV66>, 7.949825327404338), (<Material: Al2O3>, 5.3037079262845355), (<Material: CN56>, 6.1803499982835977)]
mais cette fois si j'essaie la même boucle for
{% for x, y in pt1 %}
<td width="100" style="text-align:center"><TT><span>{{ x }} : {{ y|floatformat:2}}%</span></TT></td>
{% endfor %}
j'obtiens
[ : % ( : % < : % M : % a : % t : % e : % r : % i : % a : % ........
comme une chaine de caracteres..
si dans ma fonction python je fais un slit pour eliminer les [, <,...
lt10 = [s.replace('[', '').replace(']', '').replace('<', '').replace('>', '').replace('Material:', '').strip() for s in pt1.split(',')]
je vais obtenir quelque chose comme
[u'( CV66', u'7.949825327404338)', u'( Al2O3', u'5.3037079262845355)', u'(CN56', u'6.1803499982835977)']
je sais pas si je me suis expliqué
Partager