開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
初めてのPerl 第6版 (Randal L. Schwartz (著)、brian d foy (著)、Tom Phoenix (著)、近藤 嘉雪 (翻訳)、オライリージャパン)の16章(プロセス管理)の16.9(練習問題)3.をPythonで考えてみる。
16.9(練習問題)3.
コード(BBEdit, Emacs)
sample3.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import os
import re
date = os.popen('date')
day = date.read()
if day[0] == 'S':
print('go play')
else:
print('get to work')
if re.match(r'^S.*', day):
print('go play')
else:
print('get to work')
入出力結果(Terminal, IPython)
$ ./sample3.py get to work get to work $
0 コメント:
コメントを投稿