SRL Archive - Python/Perl Help and Tutorials

Need some python help


weeps

2013-01-26 11:27:22

Well I'm importing a txt file,

k = open('k.txt', encoding = latin1)
And then transform it to a list.
However, some words like wai wai (that are in the same line in the txt file) becomes seperated, so for example it becomes ['wai', 'wai'], but i want them in the same listspot, ['wai wai', …..]

How do i do that?

Thanks

riwu

2013-01-26 20:22:31

How did you transform it to a list?

mylist = []

with open('C:/k.txt') as f:
for line in f:
mylist.append(line)

print mylist
This should work.