Created
November 3, 2017 13:53
-
-
Save molcay/f8e8de87ce335dbb7c3e2af1989a35ef to your computer and use it in GitHub Desktop.
satır halinde ki mail adreslerini alt alta yazmak için script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| input_file = "mail.txt" | |
| output_file = "cikti.txt" | |
| with open(input_file, 'r') as dosya: # with open() yapısı seni ayrı ayrı .open() .close() yapmaktan kurtarır, kendisi kapatır. | |
| oku = dosya.read() | |
| oku = oku.strip() # eğer satır sonunda gereksiz boşluk yada yeni satır karateri varsa onu temizler. | |
| mail_adresleri = oku.split(" ") | |
| liste = [] | |
| for mail_adresi in mail_adresleri: | |
| cıktı = mail_adresi.strip("<,>;") | |
| print(cıktı) | |
| liste.append(cıktı) | |
| output = "\r\n".join(liste) # listenin elemanlarını yani mail adreslerini yeni satır karakteri ile birleştirip tek bir string oluşturalım, write deyince satırlar eklenmiş olsun. | |
| if os.path.exists(output_file): # eğer dosya varsa | |
| with open(output_file, 'a') as dosya: # append mode a dosyayı açıp içine yazacak. | |
| dosya.write(output) | |
| else: | |
| print("DOSYA BULUNAMADI!!!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment