#!/usr/bin/python
import string
import re
import random
import sys
import time
import fileinput

tn = time.time()
t = str(tn)
ss = "5571"
lv = open("/usr/local/https/data/session1.txt","r")
lvr = lv.readlines()
l_lvr = len(lvr)
#print lvr
l_list = []
for i in range(l_lvr):

test = re.split('\|', lvr)
l_list.append(test)
#print l_list
for u,s,t,sp in l_list:
if s == ss:
so_list = [u, s, t, sp]
u = string.join(so_list)
#print f
s_list = u,s,t,sp
e = so_list[2]
print e
to = s_list[2]
#print st_to
too = float(to)
f = tn - too
if f < 3600:
so_list[2] = str(tn)
sn_list = so_list
print sn_list
g =string.join(sn_list)
print g
for line in fileinput.input('/usr/local/https/data/session1.txt', inplace=1):
line = line.replace(u, g)
sys.stdout.write(line)
sys.exit()

else:
#return 1
print "kK"
sys.exit()
print "no"

file line is not replacing

Please wrap your code in code tags, so it preserves the indentations and looks somwhat like Python code!

See:
http://www.daniweb.com/techtalkforums/announcement114-3.html

For Python code on Daniweb:
Please use the [code=python] and [/code] tag pair to enclose your python code.

Note, no spaces in [code=python]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.