can python do this?

Thomas Weholt thomas at cintra.no
Tue Jun 13 03:05:54 EDT 2000


On Tue, 13 Jun 2000 16:39:23 +1000, "Jason" <it at onestopent.com.au>
wrote:

>> import string
>> file = open ("file")
>> lines = file.readlines()
>> for line in lines:
>>     pair = string.split(line,":")
>>     print pair[0] +": "+ `string.split(string.strip(pair[1]),",")`
>> file.close()

The line :

file = open("file")

change "file" to the complete path of your text-file, like if your
file resides in c:\temp\music.txt, change it to :

file = open("c:\\temp\\music.txt")

And YES, the double backslashes are needed, or the \t in \temp is
interpreted as TAB. Just change that and run the script from PythonWin
or IDLE. They both come with Python, or eh ... at least IDLE does.

Thomas



More information about the Python-list mailing list