python-3.x-Basic data types

Source: Internet
Author: User
Tags set set

The current learning version is: python-3.6-4

Code:

1 """Integral type number"""2A = 2 * * 53b = A + 44c = A/45D = A//46E = a% 57F,g = 120,1128H = 3 + 4j9i = 4 + 8jTenj = h *I One Print(A,B,C,D,E,F,G,J) A  - """String Type""" -str ='wo shi Zhang san!' the #str[0] = ' 1 ' #字符串单个字符不可被修改 - Print(str[0:-3]) - Print(str[0:1]) - Print(Str[1:5])#output subscript 1 to subscript 4, which is a second to fifth character string + Print(STR * 4) - Print(str +str) +  A """the list type lists""" atList = ["Zhangsan","Lisi","Wangwu","Zhaoliu","Zhouqi"] -LIST[4] ="Xiaozhe" #elements can be modified - Print(list) - Print(List[0:3]) - Print(List +list) -  in """tuple meta-group""" - #ple = ("1", ' 2 ') toTuple = (1,2,3,4,5,6,7) + #tuple[4] = #元素不可以被修改否则报错 -Etuple = ()#Empty tuple theOtuple = (1)#single element tuple *  $ Print(Tuple[0:2])Panax Notoginseng Print(Tuple * 3) - Print(etuple) the Print(otuple) +  A """Set Set type""" theSet1 = {"Zhangsan","Lisi","Wangwu",'Lisi',"Xiao Qi"} + #per = set ("Nishi", "Woshi", "Tashi") #创建一个新的集合 -per = Set ("Nishi")#to create a new collection $ Print(Set1,per) $A = set ('Abracadabra') -b = Set ('Alacazam') -  the Print("set-a =", a) - Print("set-b =", B)Wuyi  the Print("A-B =", A-B)#the difference between A and B -  Wu Print("A | b =", a | b#the set of A and B -  About Print("A & B =", A & B)#intersection of A and B $  - Print("a ^ b =", a ^ b)#elements in A and b that do not exist at the same time -  - """Word typical""" A #Key-value pairs are stored in the form of a JSON-like representation of a middle key value +Dict = {}#a step must be declared as a dictionary type thedict["1"] ="C + +" -dict["2"] ="Java" $dict["3"] ="C" thedict["4"] ="python" the Print(dict) the Print(dict["4"]) the Print(Dict.keys ()) - Print(Dict.values ())
View Code

Results:

python-3.x-Basic data types

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.