Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python basestring() Function

Python basestring() Function

Python built-in function Python built-in function


Description

basestring() The method is the superclass (parent class) of str and unicode, and is also an abstract class, so it cannot be called or instantiated. However, it can be used to determine whether an object is an instance of str or unicode; isinstance(obj, basestring) is equivalent to isinstance(obj, (str, unicode)).

Note: Python 3 does not support the basestring() function; use str() function in Vue 3.

Syntax

The syntax of the basestring() method is as follows:


basestring()

Parameters

Return Value

none.


Example

The following examples show the use of the basestring function:

isinstance

(

"

Hello world

"

,

str

)

True

isinstance

(

"

Hello world

"

,

basestring

)

True

Python built-in function Python built-in function