split is not working

Asked by koventhan

I want to split my line and get the eCCM-U for mt,

i am using below code for it, please let me know if any issue with my code?

line="ModuleName : PBA: eCCM-U"
print line.split()
(head, mt) = line.split("(\w*):")
print mt

getting below error,

['ModuleName', ':', 'PBA:', 'eCCM-U']
[error] Stopped
[error] An error occurs at line 6
[error] Error message: Traceback (most recent call last):
File "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\sikuli-tmp2387095384227970453.py", line 6, in
(head, mt) = line.split("(\w*):")
ValueError: need more than 1 value to unpack

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

It seems you want to split the line using some RegEx: not possible with split(), you have to give a string as it appears in the line.

For more complex splits, you might use regular expression module directly:
http://docs.python.org/2.6/library/re.html

Can you help with this problem?

Provide an answer of your own, or ask koventhan for more information if necessary.

To post a message you must log in.