Python Saving long string in text file
Question: I have a long string that I want to save in a text file with the code:

`taxtfile.write(a)`

but because the string is too long, the saved file prints as:

    
    
    "something something ..... something something"   
    

how do I make sure it will save the entire string without truncating it ?


Answer: it should work regardless of the string length

this is the code I made to show it:

    
    
    import random
    
    a = ''
    number_of_characters = 1000000
    for i in range(number_of_characters):
        a += chr(random.randint(97, 122))
    print(len(a))       # a is now 1000000 characters long string
    
    textfile = open('textfile.txt', 'w')
    textfile.write(a)
    textfile.close()
    

you can put number_of_characters to whatever number you like but than you must
wait for string to be randomized

and this is screenshot of textfile.txt: <http://prntscr.com/bkyvs9>

probably your problem is in string a.

