MCPcopy Create free account
hub / github.com/doraemonext/wechat-python-sdk / to_text

Function to_text

wechat_sdk/utils.py:9–21  ·  view source on GitHub ↗

将 value 转为 unicode,默认编码 utf-8 :param value: 待转换的值 :param encoding: 编码

(value, encoding='utf-8')

Source from the content-addressed store, hash-verified

7
8
9def to_text(value, encoding='utf-8'):
10 """将 value 转为 unicode,默认编码 utf-8
11
12 :param value: 待转换的值
13 :param encoding: 编码
14 """
15 if not value:
16 return ''
17 if isinstance(value, six.text_type):
18 return value
19 if isinstance(value, six.binary_type):
20 return value.decode(encoding)
21 return six.text_type(value)
22
23
24def to_binary(value, encoding='utf-8'):

Callers 4

__str__Method · 0.90
__str__Method · 0.90
_encrypt_messageMethod · 0.90
_decrypt_messageMethod · 0.90

Calls 1

decodeMethod · 0.45

Tested by

no test coverage detected