Skip to content

Instantly share code, notes, and snippets.

@pandanote-info
Created January 16, 2019 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandanote-info/3d1ea5d7c9e00b22d010566adf6e87b1 to your computer and use it in GitHub Desktop.
Save pandanote-info/3d1ea5d7c9e00b22d010566adf6e87b1 to your computer and use it in GitHub Desktop.
標準入力から入力された文字列に対してCamelCase変換を行うPython3のプログラムの先頭の文字も大文字に書き換えるバージョン。
#!/usr/bin/env python3
import io
import sys
import re
def camelcase(matchobj):
return matchobj.group(1).upper()
sys.stdin = io.TextIOWrapper(sys.stdin.buffer,encoding='utf-8')
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
for x in sys.stdin:
print(re.sub(r'(?:^| )(.)',camelcase,x),end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment