Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 192.168.0.1:8000 = 2
- 192.168.0.10:80 = 1
- 192.168.0.100:3128 = 2
- 192.168.0.4:8080
- 192.168.0.5:7822 = 2
- 192.168.0.6:8005
- searchValue = "192.168.0.10:80"
- newNumber = 2
- f = open("datafile.txt", "r+b")
- for line in file:
- if line.split()[0] == searchValue:
- position = f.tell() - len(line) #the tell() method gives the current position in the file
- f.seek(position)
- f.write("%s = %d" % (searchValue, newNumber))
- break
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement