Python 3.x Alterando valores de elementos de string em um loop
📁 python
Como alterar o valor de um caractere de string em um loop? Código:
def getDateTimePostfix(): import datetime; dtValue = datetime.datetime.now(); retValue = str(dtValue); for sym in retValue: if sym == ':': sym = '.' retu retValue;Estou tentando ajustar a data, eliminando os ":", mas não consigo alterar caracteres individuais.
Ou é melhor fazer um loop desse tipo?
i = 0; for item in retValue: if retValue[i] == ':': retValue[i] = '.' i = i + 1;