0
Update a stored file in any variable in python
Hey guys, Any one help me that how I can update a stored value in any variable into an already existing file. In short I want to update my existing file value into new given value which is thrown by user by keyboard. Help me
3 Antworten
0
You can load the file in a variable as a string, search and replace the needed value using RegEx, then save the string to the file again.
If the file is huge, you can load and save a specific section - though this can get difficult if the string changes size.
0
Can this work at all time... Bcz my value is changed every time when I want..
0
Ashish Verma It can fail if you variable assume values which confuse the search and replace algorithm (or the Python command syntax itself). It's a matter of thinking about all possible formats your variable can take.