python - how to read ,increment by one and write back value to a network file location -


I am trying to read a value from a file "build_ver.txt" at a network location, the value of one Increasing and increasing the "Build_ver.txt" to writing the new value back and running in the following error, can anyone provide suggetions to achieve this?

  open ('\\ network \ files \ build_ver with F = value = 1 value = 1 value_IC = open (' \ \ network \ files \ build_ver.txt ',' w + ' ) Value_inc.write (value)   

Error: -

  traceback (most recent call final): file "build_ver.py", line 1 , Open with the & lt; module & gt; F: IOError ('\\ network files \ build_ver.txt', 'w +'): [Eran 22] Invalid mode ('w +') or file name : '\\ network \ x0ciles \ x08uild_ver.txt' / Case>   

Avoid backslash special characters, In your case, '\ f': form-feed and '\ b': bell gives you some You will have to escape from the backslash with the backslash or use R '' - syntax. Next problem: You do not read the file, you can only change the name of the object. If you read the object, then you have a string, Not a number, and if you convert the string to a number that you can not write it because it is not a string, in all you can get it:

  open (r ' \\ network \ files \ bui F: value = int (f.read ()) F.seek (0) f.write (str (value + 1)) with   < / Div> 

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -