Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the common built-in functions in common modules of Python

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

How to understand Python common modules commonly used built-in functions, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

As a commonly used language in computer language, Python has very powerful functions, but do you know what specific functions are included in the built-in modules of Python common module I?

In Python common module I, built-in modules are often built-in functions:

Help (obj) online help, obj can be any type

Callable (obj) to see if an obj can be called like a function

Repr (obj) gets the representation string of obj, which you can use to eval.

Rebuild a copy of the object

Eval_r (str) represents a valid python expression and returns this expression

Dir (obj) View the name visible in the name space of obj

Hasattr (obj,name) to see if there is a name in the name space of an obj

Getattr (obj,name) gets a name in the name space of an obj

Setattr (obj,name,value) is one of the name space of an obj

Name points to the object of vale.

Delattr (obj,name) removes a name from the name space of obj

Vars (obj) returns a name space of object. Expressed in dictionary

Locals () returns a local name space, represented by dictionary

Globals () returns a global name space, represented by dictionary

Type (obj) to view the type of an obj

Isinstance (obj,cls) to see if obj is the instance of cls

Issubclass (subcls,supcls) to see if subcls is a subclass of supcls

Type conversion function

Chr (I) turns an ASCII value into a character.

Ord (I) changes a character or unicode character to an ASCII value.

Oct (x) turns the integer x into an octal string

Hex (x) turns the integer x into a string represented by hexadecimal

Str (obj) gets the string description of obj

List (seq) converts a sequence into a list

Tuple (seq) converts a sequence into a tuple

Dict (), dict (list) is converted into a dictionary

Int (x) is converted to an integer

Long (x) is converted to a long interger

Float (x) is converted to a floating point number

Conversion of complex (x) to plural

Max (...) Find the value of *

Min (...) Find the minimum value

The built-in function complie used to execute the program is faster to compile and then run if a piece of code is often used.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 204

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report