How can I write a very long string in a datai?



In this code, I turn a data into a string to make a special treatment and I have problem when I want to write back into a file: The string is too long to be entierly write in the data. I have try "print xml_string[:4000]" but it seens not to work.


Here is the original code:



> #read original XML
> xml_original_file=open('XMLtoTest.xml',"r")
> xml_original_file.seek(0) #security
> xml_string=xml_original_file.read()
> xml_original_file.close
>
> xml_string = re.sub(' xmlns="[^"]+"', '', xml_string, count=1) #delete the namespace
>
> xml_temp_file=open('XMLTemp',"w")
> xml_temp_file.seek(0)
> xml_temp_file.write('test')
> xml_temp_file.close
>


Thank you


No comments:

Post a Comment