開発環境
- OS X Yosemite - Apple (OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Introducing Python: Modern Computing in Simple Packages(Bill Lubanovic (著)、 O'Reilly Media)のChapter 10(Systems)、Things to Do 10.3.を解いてみる。
Things to Do 10.3.
コード(Eacs, BBEdit)
#!/usr/bin/env python3
# -*-c doing: utf-8 -*_
import datetime
import time
with open('today.txt') as f:
today_string = f.read().rstrip()
print(today_string)
dt = datetime.datetime.strptime(today_string, '%Y-%m-%d')
print(dt)
t = time.strptime(today_string, '%Y-%m-%d')
print(t)
入出力結果(Terminal, IPython)
$ ./sample3.py 2015-03-29 2015-03-29 00:00:00 time.struct_time(tm_year=2015, tm_mon=3, tm_mday=29, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=88, tm_isdst=-1) $
0 コメント:
コメントを投稿