MMMHUHU
import datetime as dtdef try_parse(data_string: str, format_str: str):try: _d = dt.datetime.strptime(data_string, format_str) return _dexcept: return None例如,在您的情况下:try_parse(test, "%d%m%Y")print(try_parse('07052019', "%d%m%Y").strftime("%d/%m/%Y"))