How to write list of strings to file, adding newlines?

前端 未结 9 1458
借酒劲吻你
借酒劲吻你 2020-12-31 09:02
def generator():
    nums = [\'09\', \'98\', \'87\', \'76\', \'65\', \'54\', \'43\']
    s_chars = [\'*\', \'&\', \'^\', \'%\', \'$\', \'#\', \'@\',]

    data =         


        
9条回答
  •  北荒
    北荒 (楼主)
    2020-12-31 10:02

    This one works for me

    with open(fname,'wb') as f:
        for row in var:
            f.write(repr(row)+'\n')
    

提交回复
热议问题