python 函数中,os.linesep是干什么的

os.linesep字符串给出当前平台使用的行终止符。例如,Windows使用'\r\n',Linux使用'\n'而Mac使用'\r'。
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

 



posted @ 2019-10-15 15:57  乔小生1221  阅读(1956)  评论(0编辑  收藏  举报