-
-
Save toenobu/5176033 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python2.7 | |
# coding: utf-8 | |
target = u"""サンプルの文字列です。 | |
Pythonで文字列を縦書きに | |
変換します。""" | |
lst = target.split()[::-1] | |
# mapで転置して結合 | |
b = ["".join(map(lambda x:x if x != None else u" ", s)) for s in map(None, *lst)] | |
print "\n".join(b) | |
# 実行結果 | |
""" | |
変Pサ | |
換yン | |
しtプ | |
まhル | |
すoの | |
。n文 | |
で字 | |
文列 | |
字で | |
列す | |
を。 | |
縦 | |
書 | |
き | |
に | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
clone元の人に、なにか飛んでたらごめんなさい。