【python】 字符串转小写(含汉字等时仍work)

def mylower(str):
        outstr = "";
        strlen = len(str);
        idx = 0;
        while idx < strlen:
                if ord(str[idx])>0 and ord(str[idx])<= 128:
                        outstr += str[idx].lower();
                        idx += 1;
                else:
                        outstr += str[idx:idx+2];
                        idx += 2;

        return outstr;

  

 

posted @ 2013-11-07 19:40  liyuxia713  阅读(215)  评论(0编辑  收藏  举报