txt ke daftar python
with open('names.txt', 'r') as f:
myNames = [line.strip() for line in f]
Relieved Reindeer
with open('names.txt', 'r') as f:
myNames = [line.strip() for line in f]
with open('file1.txt','r') as f:
listl=[]
for line in f:
strip_lines=line.strip()
listli=strip_lines.split()
print(listli)
m=listl.append(listli)
print(listl)
# name.txt
david
mary
john
with open('names.txt', 'r') as f:
myNames = [line.strip() for line in f]
# Result
['david','mary','john']