Can't use unichr in Python 3.1

后端 未结 5 1034
别那么骄傲
别那么骄傲 2021-02-03 16:33

I\'ve been looking through the Python Cookbook (2nd Edition) to learn how to process strings and characters.

I wanted to try converting a number into its

5条回答
  •  粉色の甜心
    2021-02-03 17:27

    As suggestted by this is a better way to do it for it is compatible for both 2 and 3:

    # Python 2 and 3:
    from builtins import chr
    assert chr(8364) == '€'
    

    And you may need pip install future incase some error occures.

提交回复
热议问题