os.linesep字符串给出当前平台使用的行终止符。例如,Windows使用'
',Linux使用'
'而Mac使用'
'。
def write_file(filename, subdomains): # saving subdomains results to output file print("%s[-] Saving results to file: %s%s%s%s" % (Y, W, R, filename, W)) with open(str(filename), 'wt') as f: for subdomain in subdomains: f.write(subdomain + os.linesep)
输出:
www.yahoo.com uk.118800.yahoo.com 360.yahoo.com img.3721.yahoo.com ads.yahoo.com cms.analytics.yahoo.com tag.idsync.analytics.yahoo.com sp.analytics.yahoo.com ups.analytics.yahoo.com