Dostlar Python'da bir proje üstünde çalışıyorum. Aşağı kısıma ekleyeceğim üzere iki kısım var birinci kısım mail ikinci kısım şifre oluşturuyor tamamen random komutunu kullanarak ben ise burada oluşturulan mail ve şifreyi txt dosyasına otomatik olarak her oluşturduğunda kayıt etmesini istiyorum fakat başaramadım. Birkaç kod buldum fakat random üretilen maili ve şifreyi yazmak yerine kendisi üretilen dışında random mail ve şifre yazıyor. Desteklerinizi bekliyorum, kodlar şu şekilde;
def generate_random_email():
random_string = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(10))
random_domain = ''.join(random.choice(string.ascii_letters) for _ in range(5))
random_tld = random.choice(['com'])
random_email = random_string + '@' + 'gmail' + '.' + random_tld
return random_email
def generate_random_password():
random_password = ''.join(random.choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(12))
while (not any(c.isupper() for c in random_password)) or (not any(c.islower() for c in random_password)) or (not any(c.isdigit() for c in random_password)) or (not any(c in string.punctuation for c in random_password)):
random_password = ''.join(random.choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(8))
return random_password
Kısaca söylemek istediğim random oluşturulan kodu not etsin kendisi random bir şeyler not etmesin benim oluşturduğumu not etsin.
def generate_random_email():
random_string = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(10))
random_domain = ''.join(random.choice(string.ascii_letters) for _ in range(5))
random_tld = random.choice(['com'])
random_email = random_string + '@' + 'gmail' + '.' + random_tld
return random_email
def generate_random_password():
random_password = ''.join(random.choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(12))
while (not any(c.isupper() for c in random_password)) or (not any(c.islower() for c in random_password)) or (not any(c.isdigit() for c in random_password)) or (not any(c in string.punctuation for c in random_password)):
random_password = ''.join(random.choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(8))
return random_password
Kısaca söylemek istediğim random oluşturulan kodu not etsin kendisi random bir şeyler not etmesin benim oluşturduğumu not etsin.