7
I know that in a string I can put any characters you want, ex:
string = "qualquer coisa! @#$%ª太陽"
But what if I want to put one emoji in a string, how do I? Has any specific way?
Can I put it right into the code that works? Because I did it and it worked:
emoji = '' # criei uma string contendo um emoji
Is that right or did it work by coincidence? If not, there is another way to do it?
if the code has 5X type u1F389
– Patrício Gabriel
@PatrícioGabriel https://ideone.com/QdgCAu
– hkotsubo
updated the answer with an example of characters where Codepoint needs more than 4 hex digits.
– jsbueno
@Initially I voted to close because it wasn’t clear (at least for me and the others) that you just wanted to know how to put an emoji in a string (after all, the question mentioned a "tag", but there was no tag in the code). Perhaps it was precious of me, but I hope you understand that the idea of the site is that doubts are also useful for future visitors, so it has to be very clear, no doubt or interpretations. Anyway, I edited the question and voted to reopen...
– hkotsubo
...see if the doubt was just that (but by feedback in this answer, it seems to be). Another tip is: if you put "researched and I didn’t find", say at least what you researched (after all, a search for "python string emoji" already brings several results), and say why what you thought didn’t fit your case. This helps to focus doubt and avoids closure. The site may seem "hostile" at first, especially for those who do not know its - complicated, I admit - functioning, but it is aimed at creating a repository of knowledge (it is something that goes beyond "individual help")...
– hkotsubo
...Sometimes we can make mistakes and even exaggerate rigidity, but it is with the best of intentions. Anyway, now all that’s missing is a vote of reopening, sorry for any inconvenience, and I hope you understand that it was with the best of intentions. Finally, there is the tip to read this guide
– hkotsubo