SHARE
TWEET

Untitled

a guest Jun 20th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. num0  30
  2. num1  50
  3. num2  70
  4.      
  5. newval= 20
  6. with open(file, 'r+') as f:
  7.     for line in open(file):
  8.         if line.startswith('num1'):
  9.             val = line.strip().split()[1]
  10.             line = line.replace(str(val),str(new_val))
  11.      f.write(line + "n")
  12.  f.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top