Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/11/2012, 13:32
Avatar de shujidan
shujidan
 
Fecha de Ingreso: abril-2011
Mensajes: 121
Antigüedad: 13 años
Puntos: 5
Espacio al principio de string multiline

Cuando creo un archivo en python siempre empieza con un espacio hasta arriba lo que me da un error al querer descargar un archivo con php ya que antes de un header no debe haber ningun espacio. Alguien sabe de que forma puedo crear un archivo sin el espacio.

Código Python:
Ver original
  1. textoarchivo = r"""<?php
  2.     header('Content-Description: File Transfer');
  3.     header('Content-Type: text/plain');
  4.     header('Content-Disposition: attachment; filename=trash.torrent');
  5.     header('Content-Length: '.filesize('trash.torrent'));
  6.     readfile('trash.torrent');
  7.     exit();
  8. ?>"""
  9.  
  10. f = codecs.open('descarga.php','w','utf8')
  11. f.write(textoarchivo)
  12. f.close()

Última edición por shujidan; 07/11/2012 a las 13:38