2
I want to read the line of a file and store each word or information in a vector position. Ex: "18-10-2015 00092 65534". line[1] = 18-10-2015 line[2] = 00092 line[3] = 65534 OBS: tab between strings
2
I want to read the line of a file and store each word or information in a vector position. Ex: "18-10-2015 00092 65534". line[1] = 18-10-2015 line[2] = 00092 line[3] = 65534 OBS: tab between strings
1
To separate a string using spaces as delimiters, you use the method .split()
:
>>> "18-10-2015 00092 65534".split()
>>> ["18-10-2015", "00092", "65534"]
0
Use the string.split method() , http://www.tutorialspoint.com/python/string_split.htm
“split this string”.split(‘ ‘)
[‘split’, ‘this’, ‘string’]
>>> “split,this,string”.split(‘,’)
[‘split’, ‘this’, ‘string’]
Browser other questions tagged python
You are not signed in. Login or sign up in order to post.
First show what you have tried to do, according to what are the rules for tokenization? does not allow someone to answer without knowing what constitutes an "information" in its context.
– BrunoRB