Hi friends:
i'm beginner in python . i have a question . what does [0] mean in the below code and when should i use [0] in codes ?
- import os
-
import string
-
-
def replace(file, search_for, replace_with):
-
# replace strings in a text file
-
-
back = os.path.splitext(file)[0] + ".bak"
-
temp = os.path.splitext(file)[0] + ".tmp"
-
-
try:
-
# remove old temp file, if any
-
os.remove(temp)
-
except os.error:
-
pass
-
-
fi = open(file)
-
fo = open(temp, "w")
-