我是靠谱客的博主 孤独咖啡豆,这篇文章主要介绍使用python实现strcmp函数功能示例,现在分享给大家,希望可以做个参考。

实现这个功能我相信大家一定明白他的意思了,很简单了,下面的代码大家参考使用吧

复制代码 代码如下:

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)

最后

以上就是孤独咖啡豆最近收集整理的关于使用python实现strcmp函数功能示例的全部内容,更多相关使用python实现strcmp函数功能示例内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(127)

评论列表共有 0 条评论

立即
投稿
返回
顶部