# Buggy code
def create_menu(self, menu_data):
    """
    创建自定义菜单 ::

        client = Client("id", "secret")
        client.create_menu({
            "button":[
                {
                    "type":"click",
                    "name":"今日歌曲",
                    "key":"V1001_TODAY_MUSIC"
                },
                {
                    "type":"click",
                    "name":"歌手简介",
                    "key":"V1001_TODAY_SINGER"
                },
                {
                    "name":"菜单",
                    "sub_button":[
                        {
                            "type":"view",
                            "name":"搜索",
                            "url":"http://www.soso.com/"
                        },
                        {
                            "type":"view",
                            "name":"视频",
                            "url":"http://v.qq.com/"
                        },
                        {
                            "type":"click",
                            "name":"赞一下我们",
                            "key":"V1001_GOOD"
                        }
                    ]
                }
            ]})
    详情请参考 http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口

    :param access_token: Access Token，可以使用 :func:`get_token` 获取。
    :param menu_data: Python 字典

    :return: 返回的 JSON 数据包
    """
    return self.post(
        url="https://api.weixin.qq.com/cgi-bin/menu/create", data=menu_data
    )


# Traceback (UnicodeEncodeError)
In [1]: import six

In [2]: def to_text(value, encoding="utf-8"):
...:         if isinstance(value, (six.string_types, six.binary_type)):
...:                 return value.decode(encoding)
...:         if isinstance(value, int):
...:                 return six.text_type(value)
...:         assert isinstance(value, six.text_type)
...:         return value
...:

In [3]: print to_text(u'\u4e2d\u5348')
---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-3-9478a71004a0> in <module>()
----> 1 print to_text(u'\u4e2d\u5348')

<ipython-input-2-3b3748f845b1> in to_text(value, encoding)
1 def to_text(value, encoding="utf-8"):
2         if isinstance(value, (six.string_types, six.binary_type)):
----> 3                 return value.decode(encoding)
4         if isinstance(value, int):
5                 return six.text_type(value)

/root/.virtualenvs/wxPortal/lib/python2.7/encodings/utf_8.pyc in decode(input, errors)
14
15 def decode(input, errors='strict'):
---> 16     return codecs.utf_8_decode(input, errors, True)
17
18 class IncrementalEncoder(codecs.IncrementalEncoder):

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

# Fixed code
def create_menu(self, menu_data):
    """
    创建自定义菜单 ::

        client = Client("id", "secret")
        client.create_menu({
            "button":[
                {
                    "type":"click",
                    "name":"今日歌曲",
                    "key":"V1001_TODAY_MUSIC"
                },
                {
                    "type":"click",
                    "name":"歌手简介",
                    "key":"V1001_TODAY_SINGER"
                },
                {
                    "name":"菜单",
                    "sub_button":[
                        {
                            "type":"view",
                            "name":"搜索",
                            "url":"http://www.soso.com/"
                        },
                        {
                            "type":"view",
                            "name":"视频",
                            "url":"http://v.qq.com/"
                        },
                        {
                            "type":"click",
                            "name":"赞一下我们",
                            "key":"V1001_GOOD"
                        }
                    ]
                }
            ]})
    详情请参考 http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口

    :param menu_data: Python 字典

    :return: 返回的 JSON 数据包
    """
    return self.post(
        url="https://api.weixin.qq.com/cgi-bin/menu/create", data=menu_data
    )