Python 3.2: How to pass a dictionary into str.format()
        Posted  
        
            by 
                Robert Dailey
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Robert Dailey
        
        
        
        Published on 2011-06-26T23:43:00Z
        Indexed on 
            2011/06/27
            0:22 UTC
        
        
        Read the original article
        Hit count: 183
        
I've been reading the Python 3.2 docs about string formatting but it hasn't really helped me with this particular problem.
Here is what I'm trying to do:
stats = { 'copied': 5, 'skipped': 14 }
print( 'Copied: {copied}, Skipped: {skipped}'.format( stats ) )
The above code will not work because the format() call is not reading the dictionary values and using those in place of my format placeholders. How can I modify my code to work with my dictionary?
© Stack Overflow or respective owner