Advertisement
Guest User

Untitled

a guest
Apr 27th, 2013
34,382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. 192.168.0.1:8000 = 2
  2. 192.168.0.10:80 = 1
  3. 192.168.0.100:3128 = 2
  4. 192.168.0.4:8080
  5. 192.168.0.5:7822 = 2
  6. 192.168.0.6:8005
  7.  
  8. searchValue = "192.168.0.10:80"
  9. newNumber = 2
  10.  
  11. f = open("datafile.txt", "r+b")
  12.  
  13. for line in file:
  14. if line.split()[0] == searchValue:
  15. position = f.tell() - len(line) #the tell() method gives the current position in the file
  16. f.seek(position)
  17. f.write("%s = %d" % (searchValue, newNumber))
  18. break
  19.  
  20. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement