Skip to content

Instantly share code, notes, and snippets.

@molcay
Created November 3, 2017 13:53
Show Gist options
  • Select an option

  • Save molcay/f8e8de87ce335dbb7c3e2af1989a35ef to your computer and use it in GitHub Desktop.

Select an option

Save molcay/f8e8de87ce335dbb7c3e2af1989a35ef to your computer and use it in GitHub Desktop.
satır halinde ki mail adreslerini alt alta yazmak için script
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