Avatar ·

Python 3.x Changing string element values in a loop

📁 Advanced Python Topics

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

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

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

Or is it better to use a loop of this type?

    i = 0;    for item 

                    
                
Avatar ·

The py utility is a launcher that allows you to run the desired Python version (from those installed on this computer) using command line keys. Help for this utility:

C:\\Users\\User>py --helpPython Launcher for Windows Version 3.8.1150.1013usage:py [launcher-args] [python-args] script [script-args]Launcher arguments:-2     : Launch the latest Python 2.x version-3     : Launch the latest Python 3.x version-X.Y   : Launch the specified Python version     The above all default to 64 bit if a matching 64 bit python is present.-X.Y-32: Launch the specified 32bit Python version-X-32  : Launch the latest 32bit Python X version-X.Y-64: Launch the specified 64bit Python version-X-64  : Launch the latest 64bit Python X version-0  --list       : List

Log in to leave an answer

Blogs