Python 11 second day

Source: Internet
Author: User

One or three-dollar operation


Format:

Variable = value 1 if condition else value two


Example 1:

A=3

Name = "Wang" if a = = 2 Else "Zhang"

Print Name


Example 2:

A=input ("pls input a num:")

Print "OK" if a = = 2 Else "NO"


Second, Pycharm breakpoint debugging:

First hit the breakpoint in the key place, run debug mode, at this point to the first breakpoint of the line display highlighting, it will be executed here, but not yet executed, and then continue to the point of execution, will be executed this row, and there will be a debugger window, where all the variable values at this breakpoint are placed, The console window shows the output of the execution.


Third, all objects in Python

Everything is an object, and the object is created by the class.

such as the list of class lists, such as:

mylist=[1,33, ' Wang ']

MyList is the instantiation of a list class, and it also has all the functions of the lists class, such as Append,pop.


View the type of an object by type ()

View all features of an object via Dir ()

Help () View the object's source code, the detailed function.


Iv. built-in methods for data types

1, int integer type


The int type defaults to 10, such as:

i=10

I=int (10)

You can also improve the system, such as:

B=int ("1101", base=2)

Print "B is%s"% b


E=int ("E", base=16)

Print E


The built-in function of integral type can be seen with Dir ():

[' __abs__ ', ' __add__ ', ' __and__ ', ' __class__ ', ' __cmp__ ', ' __coerce__ ', ' __delattr__ ', ' __div__ ', ' __divmod__ ', ' __doc_ _ ', ' __float__ ', ' __floordiv__ ', ' __format__ ', ' __getattribute__ ', ' __getnewargs__ ', ' __hash__ ', ' __hex__ ', ' __index__ ' ', ' __init__ ', ' __int__ ', ' __invert__ ', ' __long__ ', ' __lshift__ ', ' __mod__ ', ' __mul__ ', ' __neg__ ', ' __new__ ', ' __nonzero ' __ ', ' __oct__ ', ' __or__ ', ' __pos__ ', ' __pow__ ', ' __radd__ ', ' __rand__ ', ' __rdiv__ ', ' __rdivmod__ ', ' __reduce__ ', ' __ Reduce_ex__ ', ' __repr__ ', ' __rfloordiv__ ', ' __rlshift__ ', ' __rmod__ ', ' __rmul__ ', ' __ror__ ', ' __rpow__ ', ' __rrshift__ ' , ' __rshift__ ', ' __rsub__ ', ' __rtruediv__ ', ' __rxor__ ', ' __setattr__ ', ' __sizeof__ ', ' __str__ ', ' __sub__ ', ' __ Subclasshook__ ', ' __truediv__ ', ' __trunc__ ', ' __xor__ ', ' bit_length ', ' conjugate ', ' denominator ', ' imag ', ' numerator ', ' Real ']


2. str character type

The built-in functions of STR can be seen with the Dir () function:

[' __add__ ', ' __class__ ', ' __contains__ ', ' __delattr__ ', ' __doc__ ', ' __eq__ ', ' __format__ ', ' __ge__ ', ' __getattribute__ ' ', ' __getitem__ ', ' __getnewargs__ ', ' __getslice__ ', ' __gt__ ', ' __hash__ ', ' __init__ ', ' __le__ ', ' __len__ ', ' __lt__ ', ' __ Mod__ ', ' __mul__ ', ' __ne__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex__ ', ' __repr__ ', ' __rmod__ ', ' __rmul__ ', ' __setattr__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' _formatter_field_name_split ', ' _formatter_parser ', ' capitalize ', ' Center ', ' count ', ' decode ', ' encode ', ' endswith ', ' expandtabs ', ' find ', ' format ', ' Index ', ' isalnum ', ' isalpha ', ' isdigit ' ', ' islower ', ' isspace ', ' istitle ', ' isupper ', ' join ', ' ljust ', ' lower ', ' lstrip ', ' partition ', ' replace ', ' rfind ', ' Rinde X ', ' rjust ', ' rpartition ', ' rsplit ', ' Rstrip ', ' Split ', ' splitlines ', ' startswith ', ' strip ', ' swapcase ', ' title ', ' transl ' Ate ', ' upper ', ' Zfill ']


This article from the "Linux World" blog, reproduced please contact the author!

Python 11 second day

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.