python - Is it possible to read spin text from 1 file & write it in another text file without bracket in python3? -


i stuck & need guys. here want program do. have 1 text file named spin.txt contains spin text {something there|source|something here} baz {why not find out more|these guys} & have text file named write.txt want read spin.txt file & write write.txt file. have done. working fine problem getting when writing write.txt file adds bracket & ' - [' wrote here'] don't want want write text. using python 3x on windows 10.

**my code :-**  import re import itertools  p = re.compile("(\{[^\}]+\}|[^\{\}]*)")  spin_comments  =open("c:\\users\\desktop\\spin.txt","r") file = str(spin_comments.readlines())  frags = p.split(file)  def options(s):     if len(s) > 0 , s[0] == '{':         return [opt opt in s[1:-1].split('|')]     return [s]  opt_lists = [options(frag) frag in frags]  write_text = open("c:\\users\\desktop\\write.txt","w")   spec in itertools.product(*opt_lists):     = ''.join(spec)     write_text.write(a + '\n')     print(a) write_comment.close() 

''.join(spec)[2:-2]

just changing in code works. reply @bit


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -