Python 3 konvertieren ISO 8601 in MillisekundenPython

Python-Programme
Anonymous
 Python 3 konvertieren ISO 8601 in Millisekunden

Post by Anonymous »

Ich erhalte ein ISO 8601-Format aus einer API-GET-Anfrage ("2020-02-25T00: 02: 43.000z"). Ich versuche, es in Millisekunden umzuwandeln, da dieses Format bei der Nutzlast des API -Post -Calls erforderlich ist. Ich habe den Code erfolgreich aus einem Linux -System ausgeführt, aber ich erhalte ValueError: Ungültige Format -Zeichenfolge < /code> von Windows.

Code: Select all

import dateutil.parser

time = "2020-02-25T00:02:43.000Z"
parsed_time = dateutil.parser.parse(time)
t_in_millisec = parsed_time.strftime('%s%f')
t_in_millisec[:-3]
< /code>

Gibt < /p>

zurück'1582588963000'
< /code>

[b] Aus Windows: < /strong> < /p>

import dateutil.parser

1 time = "2020-02-25T00:02:43.000Z"
2 parsed_time = dateutil.parser.parse(time)
----> 3 t_in_millisec = parsed_time.strftime('%s%f')

ValueError: Invalid format string
Gibt es einen Weg, um dies zu tun? [/b]

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post