2014-02-08から1日間の記事一覧
4章P75のファイルをopenしてread、readした内容をwriteしてファイルをコピーするというプログラム。 pythonで書くと下記。 #/usr/bin/env #-*- encoding: utf-8 -*- import sys def usage_error(filename): print("{0} old-file new-file".format(filename)…
3章のstderrorに対するコード。 pythonだとエラーをキャッチしてから、e.strerrorで文字列としてエラーメッセージを取得できる。 #include <string.h> char *strerror(int errnum); #/usr/bin/env #-*- encoding: utf-8 -*- def my_open(path): """ os.strerror() is </string.h>…