私はコンバータの秒に時代」を書いていますが、私は様々なエラーを得続けます。違いは、そのうちの一つ、ユーザの入力
#
!/usr/bin/env python3
# -*- coding: utf-8 -*-
#This program converts your age to seconds
from datetime import datetime
print ('Welcome to a simple age to seconds converter. ')
def get_date():
print ('Please enter the year of your birth in the format YYYY, MM, DD:')
date_of_birth = str(input())
converted_date = datetime.strptime(date_of_birth, '%Y, %m, %d')
date_now = datetime.strftime("%Y-%m-%d")
total_seconds = ((date_now - converted_date).days)*86400
return ('You have lived for:', total_seconds, 'seconds.')
print (get_date())
if __name__ == "__main__":
main()
私は、これはプログラムの最も正しいバージョンだと思うが、私は、エラーTypeError例外を取得しておく:記述子「strftimeのは、」「datetime.date」オブジェクトが必要ですが、「STR」を受けました。
誰もが、私はそれを修正することができます方法を知っていますか?また、現在の日付を入力する正確な瞬間まで秒数をカウントする方法もありますか? ありがとうございます
なぜあなたは 'main'を呼び出そうとしていますか?あなたはそのスクリプトに 'main'を定義していません。ところで、1日に86400秒があります。 –