Python notes-1

Source: Internet
Author: User

Tag: ASC Specifies bytes nal specified position pytho statistic output white

Variable naming rules:

1, can only be letters, numbers, underline any combination

2. The first character of a variable cannot be a number

3. The following keywords cannot be used as variable names:

And, as, assert, break, class, continue, Def, Del, elif, else, except, exec, finally, for , from, Global, if, import, in, is, Lambda, not, or, pass, print, raise, return, try, while, with, yield

4, general constant all uppercase letters

5. Official Recommendation: a_b_1 = variable

Computer minimum representation unit: bit binary one

Computer minimum storage unit: 8bits = 1Byte = 1 bytes

1024byte = 1KBytes 1KB 1024x768 assic character

1024KB = 1mbytes

1024mbytes = 1GB

1024GB = 1TB

Data type: (double quotation marks are double quotation marks in English)

int (integer type)

Long (integer)

Float (float type)

Complex (plural)

Boolean value (True or FALSE, True or FALSE, 1 or 0)

String: The quoted value is the string

name = "Syan yans\n" (not modifiable)

    Age = 20

    Remove white space: Name.strip () (remove only two blanks, the middle does not go)

     Segmentation

     Length: Len (name)

     Index: name[2]

     Slices: name[0:3] Gu Tou regardless of the tail

     Formatted output: msg = "My name is%s, I am%s"% (name, age)

     Splicing: msg = "My name is" + name (string and number cannot be spliced)

     list: name = [] Empty list

stored value: name = ["Syan", "Yans", "yans1", "Jack", "Rian"]

value: name[1]

change value: name[1] = "Bob"

added: Name.append ("Luci") ————— > Append to Last

Insert before specified position: Name.insert (1, "Sun")

Delete value: Del name[3]

name.remove ("Syan")

accurate to a value: Name.index ("Yans")

name[name.index ("Yans")] = "yans1"      

statistics How many duplicate values: Name.count ("yans1")

sort: Name.sort () ———— > in alphabetical order by ASCII code

name.reverse () ————— > in reverse order of ASCII code

value: Name[0:4]

interval value: Name[0:-1:2] ————— > Last value refers to length (default interval 1)

Python notes-1

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.