str.format() does not work, keyError
Posted
by Dor
on Stack Overflow
See other posts from Stack Overflow
or by Dor
Published on 2010-05-02T22:06:31Z
Indexed on
2010/05/02
22:38 UTC
Read the original article
Hit count: 218
The following code raise a keyError exception:
addr_list_formatted = []
addr_list_idx = 0
for addr in addr_list: # addr_list is a list
addr_list_idx = addr_list_idx + 1
addr_list_formatted.append("""
"{0}"
{
"gamedir" "str"
"address" "{1}"
}
""".format(addr_list_idx, addr))
Why? Using python 3.1. Thanks.
© Stack Overflow or respective owner