【发布时间】:2020-09-04 11:31:40
【问题描述】:
def dot_trick(username):
emails = list()
username_length = len(username)
combinations = pow(2, username_length - 1)
padding = "{0:0" + str(username_length - 1) + "b}"
for i in range(0, combinations):
bin = padding.format(i)
full_email = ""
for j in range(0, username_length - 1):
full_email += (username[j]);
if bin[j] == "1":
full_email += "."
full_email += (username[j + 1])
emails.append(full_email + "mars")
return emails
username = ("marsbros")
print(*dot_trick(username) , sep="\n")
我想得到与print 和sep='\n' 相同的结果,并将其逐行写入文件。
【问题讨论】:
标签: python python-3.x