Python built-in type continuation

Source: Internet
Author: User

Python built-in type continuation

Python does not allow you to use a variable that is not assigned a value. This will cause an exception.

Python assignment:

Assign multiple values at a time: Use the constant value of Tuple to assign Tuple to variable values of the same number.

You can use the Print function. _ doc _ to view most documents in Python. That is, every object in basic Python has an attribute such as _ doc.

Format String:

Python supports formatted string output.

The most basic usage is to insert a value into a string with the string format character % s (note that s is a lower-case Python case sensitive.

>>> K = "Uid"

>>> V = "SA"

>>> "% S = % s" % (K, V) Note that (K, V) is a Tuple

'Uid = Sa'

Only the Tuple of an element: Tup = (A,) must have A comma before the parentheses, so that Python can identify this as A Tuple ..

The % f format character option corresponds to a decimal floating point number, which can specify the decimal precision.

%. 2f indicates that only two decimal places are printed.

Ing List

One of the powerful features of Python is its List parsing. It provides a compact method that maps a List to another by applying a function to each element in the List.


Parse the List without changing the original List.


The Join function can link any List containing strings to a single string! String Join method!

The Join function can only be used for the List where the element is a string! It does not perform any forced type conversion.

The split method can split the string into a List.

Split can have a second parameter, indicating the number of splits!

Tip: search by split

Anythin. split (delimiter, 1) is a useful technique. You can search for a substring and then separate the first and last parts of the string.


June

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.