Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Python で気象観測所用の小さなプログラムを作成しましたが、すべて問題なく動作していますが、小さな問題が 1 つあります。
出力は次のように表示されます。
2014/5/18 04:03:41 2014/5/18 19:47:41
のように表示させたい
04:03:41 19:47:41
これを行う簡単な方法はありますか?文字を削除することを考えていましたが、変換するよりもボッジのように聞こえます。
助けてくれてありがとう
In [66]: t="2014/5/18 19:47:41".split() In [67]: print t[-1] 19:47:41
文字列を分割して、時間である最後の要素を取得する場合。
t="2014/5/18 04:03:41" from datetime import datetime str_time= datetime.strptime(t,'2014/5/18 %H:%M:%S').time() In [72]: print str_time 04:03:41
日時ドキュメント