hi...

I have a value, value=4501-E001

I am concerned about only the value before hyphen i.e., 4501

I need to check whether various values begin with 4501, followed by something, n am not concerned about "something" that follows.

How can this splitting be done in python?

Don't need to .split('-') but you can check directly begining by startswith.

Edited 6 Years Ago by pyTony: n/a

Don't need to .split('-') but you can check directly begining by startswith.

thanx for the reply...but the value is an octet string, n when i tried startswith, it said octetstring has no attribute startswith

thanx for the reply...but the value is an octet string, n when i tried startswith, it said octetstring has no attribute startswith

yes...i got a simple solution..

here s it, hoping it might help some newbie like me:)

if value[:4]== '4501':
print "xxx..whatever..."

Edited 6 Years Ago by novice20: n/a

octet-string?? Give running code I never heard such a thing? It has not string representation for str function?

if str(value).startswith(start):

Edited 6 Years Ago by pyTony: n/a

yes...i got a simple solution..

here s it, hoping it might help some newbie like me:)

if value[:4]== '4501':
print "xxx..whatever..."

What you can do with an object depends entirely on its class. I suspect that your object's class is pyasn1.type.univ.OctetString. You should probably be able to convert the value to a python string by using mystring = str(value) .

This question has already been answered. Start a new discussion instead.