I am looking to remove the space separating the date and the time from a python datetime object. I am using strptime "%Y-%m-%dT%H:%M:%S.%f", so I do not know why there is a space included to begin with.
Code:
import datetime
start_timestamp = "2022-11-23T10:08:00.000"
date_time_start = datetime.datetime.strptime(start_timestamp, "%Y-%m-%dT%H:%M:%S.%f")
print(date_time_start)
Output:
2022-11-23 10:08:00
Desired output:
2022-11-23_10:08:00
strptimefunction returns a datetime, not a string. When you print it, a string representation of the datetime value is printed, and that, by default, contains a space, which is a completely sensible default.