Using python to implement the STRCMP function function example
- 2020-04-02 13:30:39
- OfStack
Implement this function I believe you must understand his meaning, very simple, the following code you refer to use it
def strcmp(str1,str2):
i = 0
while i<len(str1) and i<len(str2):
outcome = cmp(str1[i],str2[i])
if outcome:
print outcome
return outcome
i +=1
return cmp(len(str1),len(str2))
str1='dfdcd'
str2='dfdc'
print strcmp(str1,str2)
print cmp(str1,str2)