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

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

    data =         


        
9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-31 09:42

    Python's print is the standard "print with newline" function.

    Therefore, you can directly do, if you use Python 2.x:

    print  >> data, c+n
    

    If you use Python 3.x:

    print(c+n, file=data)
    

提交回复
热议问题