python3中怎么判断传入的参数是否是unicode
黄舟
黄舟 2017-04-18 09:52:30
0
2
545

网上的教程都说使用isinstance( XXX , unicode)来判断
但是我在python3下这么使用会报name 'unicode' is not defined的错误,想看一下isinstance()是怎么实现的,传入参数的说明,结果发现isinstance的定义是下面这个样子,完全看不出想要判断unicode该传入什么参数,顺带问一下为什么python好多自带的参数都是这么定义的,def XXX(): return none,没有功能实现的代码

def isinstance(object, class_or_type_or_tuple):
  """ isinstance(object, class-or-type-or-tuple) -> bool
  
  Return whether an object is an instance of a class or of a subclass thereof.
  With a type as second argument, return whether that is the object's type.
  The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for
  isinstance(x, A) or isinstance(x, B) or ... (etc.). """
  return None

回到正题,python3下该怎么判断是否unicode呢?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

모든 응답(2)
Ty80

Python 3의 기본 str은 유니코드이므로 str을 직접 판단할 수 있습니다.

으아악
伊谢尔伦

cpython의 맨 아래 레이어는 C로 구현됩니다. 내장 함수와 객체의 py 소스 코드는 단지 장식용일 뿐이며 몇 가지 설명을 제공하기 위한 것입니다

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!