Can't use unichr in Python 3.1

后端 未结 5 1199
别那么骄傲
别那么骄傲 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:17

    In case you need to run in both python 2 and python 3, you can use this common syntax (the unused syntax would point to the new one)

    try:
        unichr
    except NameError:
        unichr = chr
    

提交回复
热议问题