Discuss / Python / 代码在mac中运行错误

代码在mac中运行错误

Topic source

linwoain

#1 Created at ... [Delete] [Delete and Lock User]

使用了mac10.10自带的python2.7.10

>>> ord('A')
65
>>> ord('中')
20013
>>> chr(66)
'B'
>>> chr(25991)
'文'


>>> ord('中')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ord() expected a character, but string of length 3 found
>>> 

>>> chr(25591)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: chr() arg not in range(256)
>>>

chr如果用unichr代替正常

ord不行

AzioAuditore

#2 Created at ... [Delete] [Delete and Lock User]

教程开始就说了使用Python3.5 3.x和2.x许多是不兼容的

Bill不河蟹

#3 Created at ... [Delete] [Delete and Lock User]

要用3.5.x版本的。3.x和2.x有一些不同。


  • 1

Reply