how to edit a line (overwright and replace) in python -


I have a file and I need to edit a specific line within that file

This line needs to be edited:

  "file: /// c: /xxxxxxx/nameList.json#/"   

In:

  & lt; Xxxx = "xxxx: //xxxx.com/xxxx//nameList.md" & gt; Name list / xxxxxx /   

How should I do this?

Note that somehow I need to store "name list" I am writing a script and part of the "name list" is different for different files

Additional information:

  1. Whatever is to be done in front of the name's name "and whatever" after the name list ".... < / Li>

  2. But string "name list" is arbitrary for various files. For example, the first file will have name 1 list, the second name will be 2 ... etc. I need to keep nameListX for different files

      Regex = re.compile ("file: /// c: / ([^ /] +) /nameList.json#/") replacer = lambda g: '& lt; {0} = "{0}: // {0} .com / {0} //nameList.md" & gt; Open the name list / {0} /'.format(g.groups()[0]) ("Output.txt", "w"): in the open for line ("input.txt"): F.write (re.sub (regex, replacer, line))   

    Maybe ... I do not know what else xxxx has to do with xxxx in the first one

    If you want "nameList" section then

      regex = re.compile ("file: /// c: / [^ /] + / ([.] +) \ .json # / ") replacer = lambda g: '& lt; Xmlns = "Http://blahblah.com/sub1//{0}.md">{0} /xxxx/'.format(g.groups()[0]) with open (" output.txt " , "W"): for open in the line ("input.txt"): f.write (re.sub (regex, replacer, line))    < / Html>

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -