twitter - Finding and replacing keywords in an email file - Python -


I'm trying to type a program into Python so that you can use Twitter with user's name and email. Can send an email I'm trying to use this definition to find and replace keywords ('$ NAME', '$ EMAIL', etc.) preform def editEmail (): email = open (destinationTitle , 'R +') for the line in email: email.write (line.replace ('$ NAME', account.name)) Email Type (line. Location ('$ EMAIL', email)) email.write (line.replace ('$ USRNAME', targetHandle)) Email Type (line space ('$ PROFILEIMG', account.profile_image_url)) email. I am using a Python-tweeter wrapper and the user enters the email address and the Twitter username, But the image, url and name are removed from the Twitter account (hence the account name, account.url, etc.)

This is where comes from destinationTitle :

  destinationTitle = str ("email /" + account.name + "- generated Spear.mmlx") modify shutil.copy ('email.emlx', destinationTitle )Email ()  < / pre> 

problem Are that it does not replace the $ words with the correct word's, but below is a strange thing that he is emulating the lower half of the email 5 times. Here's a small example, in this example it turned a $ EMAIL to random and I do not know why?! (I'm using a Twitter email for testing):

  From [...] From: Twitter & lt; password@twitter.com> From: Twitter & lt; password@twitter.com> From: Twitter & lt; password@twitter.com> To: Adam & lt; $ EMAIL & gt; To: $ NAME & lt; me@adam.com> To: $ NAME & lt; $ EMAIL & gt; To: $ NAME & lt; $ EMAIL & gt; To: $ NAME & lt; $ EMAIL & gt; Subject: Re-activate your twitter account Subject: Re-activate your twitter account Subject: Re-activate your twitter account Subject: Re-activate your twitter account Subject: Re-activate your twitter account MIME-Version: 1.0 MIME-Version: 1.0 MIME-Version: 1.0 [...]    

Looking for a template engine you can find many options Maco and Jinja 2 are famous.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -