10 August 2021

How to read a file, which only contains a string, into Python, and then convert the string into a list?

 How to read a file, which only contains a string, into Python, and then convert the string into a list?


from pathlib import Path

txt = Path('filename.txt').read_text()

list_ = list(txt.split('; '))

No comments:

Post a Comment