あっきぃ日誌

鉄道ブログのような技術系ブログのようななにか

とつぜんの

Pythonのコードもなんか気づいたら仕事で書かされていたので、習作。でもこれ文字のカウントまわりがおかしい。

def totsuzenno(string,returnstr):
        strbytes = len(string)
        if strbytes % 2:
                count = strbytes - 2
        else:
                count = strbytes - 1
        line1 = '_人'
        line2 = '> ' + string + ' <' + returnstr
        line3 = ' ̄^'
        for i in range(count):
                line1 += '人'
                line3 += 'Y^'
        line1 += '_' + returnstr
        line3 += ' ̄' + returnstr
        return line1 + line2 + line3 + returnstr
print totsuzenno("Python", "\n")
_人人人人人人_
> Python <
 ̄^Y^Y^Y^Y^Y^ ̄