0

Hi All,

I am using the .search function.

strValue="XXX"
strTemp1="YYYXXX"
strTemp= strTemp1.search(strValue)

Python is not able to recognise the .search function.
AttributeError: 'str' object has no attribute 'search'

What should I import for this?
Please help!

3
Contributors
2
Replies
8
Views
8 Years
Discussion Span
Last Post by scru
0

Python is not able to recognise the .search function.
AttributeError: 'str' object has no attribute 'search'

yes...that would be the response
to find the available methods for string class..try help(string) at the python prompt...
that shud help

Peace...

1

If you want to just find out if one string is contained inside another:

strvalue1 in strvalue2

If you want to find out how many occurrences of one string there are in another:

num = strvalue.count(strvalue2)

If you want to find the index of the first occurrence of one string in another:

ind = strvalue1.find(strvalue2)
Votes + Comments
nice help
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.