Python automated test Aries-week3 slices + tuples

Source: Internet
Author: User

Name =' Zcl,py,zyz '
names = [' Zcl ',' Py ',' Zyz ']
Print (names[0])
Print (names[0:2])#切片就是从里面取几个元素, from the first to the end of the first few. Gu Tou regardless of the tail when the value is taken.
Print (names[1])

#切片操作对字符串也适用
name1=[' Zcl ',' Py ',' Zyz ']
Print (name1[2])

num =ListRange10)) #用range生成列表 need to use list to force type conversion
Print (num)

NUM1 = list (range (1,21)" #用range生成列表, You need to use list to force the type conversion
print ( # # #), NUM1)
print (Num1[1: 10:2]) #print (num[from the first: take several: Take one from the other if you don't write it every other one])
print (num1[::-< span style= "color: #0000ff" >1]) #print (num[: Take a few: take a few, one by one if not written) ##### #反转了字符串, same as recover


#和列表一样, it's just immutable variables.
#定义元组时, if the tuple has only one element, add a comma after the element, or it will be a string
Lis = []#列表这样定义
TP = (' 127.0.0.1 ',' 3306 ')
#lis [0]= ' 3306 ' #不能这样写 because this list is empty, subscript 0 does not exist, use append or insert
print (LIS)
print (TP)

TP = ( ' 127.0.0.1 ', ' 3306 ') #元组
names = [1,2,3," Lingyul ", Panyang '] #列表
Name = ' lingyul,cyc '
New_lis = tuple (LIS)
print (type (new_lis))

#强制类型转换的int float str list tuple
 

Python automated test Aries-week3 slices + tuples

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.