When MySQL version greater than 5.5.3 have utf8mb4 CHARACTER SET which can store emoji.
But when MySQL version lower than 5.5.3 can’t directly store emoji.
And can store emoji by using pyemoji’s encode/decode & replace & entities function.
Similar: https://pypi.python.org/pypi/pymoji
Installation
pip install pyemoji
Usage
encode/decode:
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
Type "copyright", "credits" or "license" for more information.
IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import pyemoji
In [2]: pyemoji.encode(u'笑脸表情:😄')
Out[2]: '\\u7b11\\u8138\\u8868\\u60c5\\uff1a\\U0001f604'
In [3]: print pyemoji.encode(u'笑脸表情:😄')
\u7b11\u8138\u8868\u60c5\uff1a\U0001f604
In [4]: pyemoji.decode('\\u7b11\\u8138\\u8868\\u60c5\\uff1a\\U0001f604')
Out[4]: u'\u7b11\u8138\u8868\u60c5\uff1a\U0001f604'
In [5]: print pyemoji.decode('\\u7b11\\u8138\\u8868\\u60c5\\uff1a\\U0001f604')
笑脸表情:😄
replace:
In [6]: pyemoji.replace(u'笑脸表情:😄') Out[6]: u'\u7b11\u8138\u8868\u60c5\uff1a\ufffd' In [7]: print pyemoji.replace(u'笑脸表情:😄') 笑脸表情:� In [8]: pyemoji.replace(u'笑脸表情:😄', '') Out[8]: u'\u7b11\u8138\u8868\u60c5\uff1a' In [9]: print pyemoji.replace(u'笑脸表情:😄', '') 笑脸表情:
entities:
In [10]: pyemoji.entities(u'笑脸表情:😄') Out[10]: u'\u7b11\u8138\u8868\u60c5\uff1a😄' In [11]: print pyemoji.entities(u'笑脸表情:😄') 笑脸表情:😄
Params
unic:
In [4]: import pyemoji
In [5]: pyemoji.encode('笑脸表情:😄')
Out[5]: '\\u7b11\\u8138\\u8868\\u60c5\\uff1a\\U0001f604'
In [6]: pyemoji.encode(u'笑脸表情:😄')
Out[6]: '\\u7b11\\u8138\\u8868\\u60c5\\uff1a\\U0001f604'
Release files for pyemoji 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyemoji-1.0.4.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyemoji-1.0.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 9.0 kB
Release files / pyemoji-1.0.4.tar.gz
| Download URL | pyemoji-1.0.4.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2fabc96573bfe4777ef7886a179e5859d1f8b4db5d66c4930c6e94288c119e2
|
|
BLAKE2b-256 checksum How to use checksums |
4f3f64950b2bcde25ddf16035ce27eb5c491b117dc34cb1729e86163fc10bad3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pyemoji-1.0.4-py2.py3-none-any.whl
| Download URL | pyemoji-1.0.4-py2.py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ad99d81c3778ced1f48440ee1f800b1a4e4c42f431865ceaae18438ff1440061
|
|
BLAKE2b-256 checksum How to use checksums |
e7aaf4056116c383c5b2e052641775ff8150a0718199b7d34b54d46f54807d9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |