Created
June 4, 2016 13:36
-
-
Save anonymous/1460ad8f852cb624c17a8dec62dd3146 to your computer and use it in GitHub Desktop.
Pythonオレメモ >>151 インデントを全角スペースに
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
# -*- coding: utf-8 -*- | |
''' | |
先頭インデントを全角スペースへ変換 | |
''' | |
import sys | |
import re | |
for line in sys.stdin: | |
line = line.rstrip() | |
ma = re.match(r'^( +)(.*)', line) | |
if ma: | |
line = ' ' * (len(ma.group(1)) // 4) + ma.group(2) | |
else: | |
ma = re.match(r'^(\t+)(.*)', line) | |
if ma: | |
line = ' ' * len(ma.group(1)) + ma.group(2) | |
print(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment