我试图将用户选择写进文本档案。 这一工作是完美的。 使用者的选择也一样:
页: 1
2 P-4, 2 P-3, 2 FS, 2 NS
3
..
def write_log(name, total):
# This writes a passed info into text
logfile = open("text.txt", "a")
towrite = name
towrite += " "
towrite += total
towrite += "
"
try:
logfile.write(towrite)
finally:
logfile.close()
return write_log
www.un.org/Depts/DGACM/index_spanish.htm
I am trying to replace user choice with another names. something like this:
www.un.org/Depts/DGACM/index_spanish.htm
change = [(页: 1, triangle), (2 P-4, 2 P-3, 2 FS, 2 NS, square), (3, rectangle), (4, pentagon)]
www.un.org/Depts/DGACM/index_spanish.htm
when i do this it does not work
www.un.org/Depts/DGACM/index_spanish.htm
def write_log(name, total):
# This writes a passed info into text
change = [(页: 1, triangle), (2 P-4, 2 P-3, 2 FS, 2 NS, square), (3, rectangle), (4, pentagon)]
for search, replace in change:
name = name.replace(search, replace)
logfile = open("text.txt", "a")
towrite = name
towrite += " "
towrite += total
towrite += "
"
try:
logfile.write(towrite)
finally:
logfile.close()
return write_log