python 判断两个数组是否是彼此的排列

判断两个数组是否是彼此的排列

return sorted(str1) == sorted(str2)

麻烦一些的做法

        if str1 is None or str2 is None:
            return False
        char1=[]
        for i in str1:
            char1.append(i)
        check=''
        for i2 in str2:
            if i2 in char1:
                check = check+i2
                char1.remove(i2)
        if (str2 == check) and (len(char1) == 0):
            return True
        else:
            return False
posted @ 2021-03-10 15:44  maxsmile17  阅读(104)  评论(0编辑  收藏  举报