2017-03-15 6 views
0

タプルを使用して時間と日付を変換するには、スパイダーを使用する必要があります。タプルタプルで時刻と日付を使用する

それはdef problem3_3(month, day, year)と同じです。日付をあるフォーマットから別のフォーマットに変換する関数を書きます。

具体的には、06/10/2016June 17, 2016に変換する必要があります。実際には、独立した整数(numbers)と あなた 意志入力6、17、および2016は機能が6月17日、2016年

として日付をアセンブルし、印刷します私はあなたがtuple months = ("January", "February", "March", ...) にストアを作成することを示唆しています月の名前。 それでは、months[1]という名前で2月 という名前にアクセスするのは簡単です。 助けてください。おかげ

+0

感謝の先生に、それは私にこのエラーが発生しますので、私は、どのように連結することができます(TypeError:唯一のタプルするタプル(ない「STR」)を連結することができます)[解析の日付文字列と変更形式の –

+0

可能な複製](http://stackoverflow.com/questions/2265357/parse-date-string-and-change-format) – Juggernaut

答えて

0
def problem3_3(month, day, year): 
""" Takes date of form mm/dd/yyyy and writes it in form June 17, 2016 
    Example3_3: problem3_3(6, 17, 2016) gives June 17, 2016 """ 
months=("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") 

for month in months: 

    #print (month[5] +" "+str(day)+", "+str(year)) 
    print (months[month-1] +" "+ str(day)+", "+ str(year)) 
関連する問題