简体   繁体   中英

trying to put a line break (carriage return?) through tweepy

I have created a python script for sending a tweet out to twitter. I am having an issue with sending a carriage return / line break. Normally I would like the command \n in python but this doesn't work with tweepy and it send the text to twitter including the \n.

The end of my script looks like this:

phrase = "Hello World! \n I am sending a tweet from a bot!"    
api.update_status(phrase)

and the result on twitter is:

Hello World! \n I am sending a tweet from a bot!

and what I want is:

Hello World!    
I am sending a tweet from a bot!

How can I do this with my script?

That's unusual, what you tried should be working.

For whatever reason, it doesn't seem to be. This should work instead:

phrase = """
Hello World!

I am sending a tweet from a bot!
"""    
api.update_status(phrase)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM