Earlier we have learned many functions provided by strings, including split(), join(), find(), index(), etc.,
but this is far from all its methods. Due to the limited space, this chapter can only give you some of
the most used functions. As for other functions, the reader can check them by using the dir() and help()
functions introduced in this section.
The Python dir() function is used to list the entire contents of a class or a module, including variables,
methods, functions, and classes. Its usage is:
obj represents the object to be viewed. obj can be left unwritten, at which point dir () lists the
variables, methods, and defined types in the current scope.
The Python help() function is used to view the help documentation of a function or module. Its usage is:
obj represents the object to be viewed. obj can be left unwritten, and help() will enter the help
After mastering the above two functions, we can review the usage and functions of all methods,
functions, variables, and classes in Python.
[Example] Use dir() to view all methods supported by the string type (str):