4
4

More than 5 years have passed since last update.

PerlユーザーがPythonで忘れがちな構文

Posted at

文字コード指定で開く、正規表現でSplit

import codecs
for line in codecs.open(file, 'r', 'utf8'):
  arr = re.compile(r' ?= ?').split(line)

Chomp

str.rstrip()

Dict(ハッシュ)をキーでソート

for k, v in sorted(dic.items()):
  print(k + ' = ' + v.rstrip())
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4