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 ?
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 ?
Code:
import os
import string
def replace(file, search_for, replace_with):
# replace strings in a text file
back = os.path.splitext(file)[B][0][/B] + ".bak"
temp = os.path.splitext(file)[B][0][/B] + ".tmp"
try:
# remove old temp file, if any
os.remove(temp)
except os.error:
pass
fi = open(file)
fo = open(temp, "w")
Comment