writeLines

writeLines(text, con, type='wt')

Write text to a file

Parameters

Name Type Description Default
text Union[str, List[str]] The text to write to a file required
con str The path to the file required
type str String indicating how to open the file. Defaults to ‘wt’ 'wt'

Returns

Name Type Description
str the path to the file where the text is stored

Examples

>>> from rlike import *
>>> f = writeLines(text = 'Hello world. Some more text.', con = 'fname.txt')
>>> x = readLines('fname.txt')
>>> x
['Hello world. Some more text.']
>>> f = writeLines(text = ['I', 'want', 'to', 'break free.'], con = 'fname.txt')
>>> x = readLines('fname.txt')
>>> x
['I', 'want', 'to', 'break free.']