We can use the type() function to figure out what class a variable or value belongs to. For example, type(" ") tells us that this is a string class. The only attribute in this case is the string value, but there are a bunch of methods associated with the class. We've seen the upper() method, which returns the string in all uppercase, as well as isnumeric() which returns a boolean telling us whether or not the string is a number. You can use the dir() function to print all the attributes and methods of an object. Each string is an instance of the string class, having the same methods of the parent class. Since the content of the string is different, the methods will return different values. You can also use the help() function on an object, which will return the documentation for the corresponding class. This will show all the methods for the class, along with parameters the methods receive, types of return values, and a description of the methods.
Christine Rafla
Email us at - techlaboffice77@gmail.com
In questa pagina del sito puoi guardare il video online 50 Classes and Objects in Python | Python [ COMPLETE COURSE ] della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Tech Lab 21 agosto 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 46 volte e gli è piaciuto 0 spettatori. Buona visione!