Outline
the writelines () method is used to write a sequence of strings to the file.
This sequence may be generated by an iterative string object, such as a list of strings.
Wrap the need to develop a newline \ n.
grammar
the writelines () method has the following syntax:
fileObject.writelines( [ str ])
data = ['a','b','c'] with open("data.txt","w") as f: f.writelines(data)
Output:
For double data list
data = [ ['a','b','c'],['a','b','c'],['a','b','c']] Open with ( " data.txt " , " W " ) AS F: for I in Data: # for double data list I = STR (I) .strip ( ' [ ' ) .strip ( ' ] ' ). Replace ( ' , ' , '' ) .replace ( ' \' ' , ' ' ) + ' \ n- ' # in which each of a list of strings normalized to f.write (i)
Output:
Part of the contents from the network