python-List tuple-list tuple

Source: Internet
Author: User
Tags generator aliyun

Lists List
[Vale,...] Can be added to any type of data, and can be nested, indefinite length

Student = ["Beimenchuixue", "Mayun", "Mahuiteng", "naichadong"]product = ["blog", "TaoBao", "Weichat", "JD"]score = ["Beim Enchuixue ", [90, 80, 66, 77, 99]

List Access
1. Specify insert. insert
2. Insert at the end. Append
3. Value deletion. Remove
4. Know the index to delete and return the value. Popdel
5. Clear the list. Clear
6. Reverse the list. Reverse
7. Sorted list. sort
8. List of extensions. Extend
9. Copy the list. Copy
10. Indexed Index
11. Define an empty list [] list ()

Product = ["Bokeyuan", "TaoBao", "Weichat", "JD", "Baiduyun", "Aliyun"]product.insert (1, "Jinritoutiao") print (product) Product.append ("Douyin") print (product) product.remove ("JD") print (product) del_product = Product.pop (0) print (DEL_ Product) print (product) Product.reverse () print (product) # Product.sort (Lambda x:x[0],) # print (product) two_product = [" Weiruan "," Centos "," Nginx "]product.extend (two_product) print (product) copy_product = Product.copy () print (Copy_ Product) Print (Copy_product.index ("Aliyun")) Copy_product.clear () print (copy_product) empty_list = []empty_list_two = List () print (empty_list, empty_list_two) print (Product.count ("Aliyun")) Tuple_product = ("Bokeyuan", "TaoBao", " Weichat "," JD "," Baiduyun "," Aliyun ") Print (Tuple_product.index (" Weichat ")) Print (Tuple_product.count (" Weichat "))

Tuple tuples
(Value, ...)
1. Declaring data immutable, avoiding hidden errors, fixed data recommendations using tuples
2. Can add any type of data, and can be nested, a single value needs to be added,
3. Define empty tuple () tuple ()

Tuple_product = ("Bokeyuan", "TaoBao", "Weichat", "JD", "Baiduyun", "Aliyun") Print (Tuple_product.index ("Weichat")) Print (Tuple_product.count ("Weichat"))

The meaning of ()
1. Forcing or emphasizing priority order
2. Mathematical Operation type ((5)) result is int
3. Empty tuples () and tuples (value, ...)
4. Generator () + for
5. The regular expression is treated as a character and takes its matching character (re)

result = Not True or Trueresult_two = Not (True or true) print (result, result_two) print (Type ((6 + 7)) Print (Type (())) genera Tor = (I for I in range) print (generator.__next__ ()) One_str = "Simple is better than complex." Regular = r "\w+" Import refind_list = Re.findall (regular, one_str) print (find_list)

python-List tuple-list tuple

Related Article

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.