RSS Forums RSS
Please support our Python advertiser: Programming Forums
Views: 1058 | Replies: 1
Reply
Join Date: Mar 2007
Posts: 6
Reputation: nitinloml is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
nitinloml nitinloml is offline Offline
Newbie Poster

suggest

  #1  
Mar 30th, 2007
#!/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[i])
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Posts: 2,536
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 11
Solved Threads: 178
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: suggest

  #2  
Mar 31st, 2007
Please wrap your code in code tags, so it preserves the indentations and looks somwhat like Python code!

See:
http://www.daniweb.com/techtalkforum...ment114-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]
Last edited by vegaseat : Mar 31st, 2007 at 1:38 am.
May 'the Google' be with you!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:23 am.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC