Avatar ·

Python 3.X Changing the values of the line elements in the cycle

📁 Advanced Python Topics

How to change the value of a character in a string in a loop? Code:

def getDateTimePostfix():
    import datetime;
    dtValue = datetime.datetime.now();
    retValue = str(dtValue);
    for sym in retValue:
        if sym == ':':
            sym = '.'
    return retValue;

I'm trying to format the date by removing ":" characters, but I can't change individual characters.

Or is it better to make a loop like this?