steveha already said truncating. That will round you down. But if you want to round to the nearest digit, the way to round numbers in general is to add 5 to the place of decimals you would be cutting off, before doing the truncating. So for example to round 12.3456 to 3 places of decimals, add 0.0005; that gives you 12.3461 which you then truncate to 3 characters after the point, giving you 12.346.
The question is, how to add 5 to the next place of decimals -- correctly. So you can't just consider the microseconds, if you round up .9995 seconds when it's just before midnight on New Year's eve, the carry might go all the way up to the year!
But you can use a timedelta. Then the time calculation is correct and you can just truncate to get your correctly-rounded value.
To round to 3 places of decimals in seconds, you want to add 0.0005 seconds = 500 microseconds. Here are 3 examples: first, round 0.1234 seconds to 0.123, then round 0.1235 seconds to 0.124, then have the carry propagate all the way when you should be kissing someone to wish them happy new year and instead you're doing Python:
>>> r = datetime.timedelta(microseconds=500)
>>> t = datetime.datetime(2023,1,2,3,45,6,123456)
>>> (t+r).strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
'2023-01-02 03:45:06.123'
>>> t = datetime.datetime(2023,1,2,3,45,6,123556)
>>> (t+r).strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
'2023-01-02 03:45:06.124'
>>> t = datetime.datetime(2023,12,31,23,59,59,999500)
>>> (t+r).strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
'2024-01-01 00:00:00.000'