手机
当前位置:查字典教程网 >脚本专栏 >python >使用python实现strcmp函数功能示例
使用python实现strcmp函数功能示例
摘要:实现这个功能我相信大家一定明白他的意思了,很简单了,下面的代码大家参考使用吧复制代码代码如下:defstrcmp(str1,str2):i=...

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

复制代码 代码如下:

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使用mysqldb连接数据库操作方法示例详解

python从ftp下载数据保存实例

python实现批量转换文件编码(批转换编码示例)

python实现dnspod自动更新dns解析的方法

python list转dict示例分享

使用python将mdb数据库文件导入postgresql数据库示例

python解析文件示例

python连接mysql数据库示例(做增删改操作)

python实现ftp客户端示例分享

Python的print用法示例

精品推荐
分类导航