[Python] Why the following code in python is failing to write 10L items of list into a file?...

Discussão em 'Python' iniciado por Stack, Março 11, 2025.

  1. Stack

    Stack Membro Participativo

    em1 = {chr(random.randrange(65,122))+
    chr(random.randrange(65,122))+
    chr(random.randrange(65,122))+
    chr(random.randrange(65,122))+
    random.choice(['@gmail.com','@yahoo.co.in','@hotmail.com','rediffmail.com'])
    for _ in range(1000000)}

    with open('emails.txt','w') as fp:
    i = 0
    for x in em1:
    fp.write(str(i)+': ' + str(x) +'\n')
    i = i+1


    Last 3 lines in the file

    988242: NHhF@gmail.com

    988243: WusOrediffmail.com

    988244: _BlI@gmail.com

    Continue reading...

Compartilhe esta Página