入门第二课
print("Hello wrod") #这是注释 if True: print("zhonggg") else: print("ellllll") import keyword #print(keyword.kwlist) a,b=5,8 print(type(a)) print(b) print("abcd\nefg"); word="Python" print(word[0]); tylist=["aa","bb"]; print(tylist*2) sites = {'Google', 'Taobao', 'Runoob', 'Facebook', 'Zhihu', 'Baidu'} if 'Runoob' in sites: print("在集合中") else: print("不在集合中") a = set('abracadabra') b = set('alacazam') # print(a,b); # print(a-b); # print(a&b); # print(a|b); dd=set('111233'); print(dd); thisset = set(("Google", "Runoob", "Taobao")) thisset.add("HEllword"); print(thisset); hp=['Google', 'Runoob', 1997, 2000]; #hp.__add__("qqq") print(hp) tup1 = ('Google', 'Runoob', 1997, 2000) print(tup1) tup1 = (12, 34.56) tup2 = ('abc', 'xyz') tup3=tup1+tup2 print(tup3) tup = ('Google', 'Runoob', 1997, 2000) print(tup) del tup print("删除后的元组 tup : ") dict = {'Name': 'Runoob', 'Age': 7, 'Class': 'First'} str(dict); print(str(dict),len(dict),type(dict)); del dict['Name'] # 删除键 'Name' print ("dict['Age']: ", dict['Age']) print(dict); dict.clear() # 清空字典 print(dict); del dict print(dict) #!/usr/bin/python3 ''' 这是多行注释,用三个单引号 这是多行注释,用三个单引号 这是多行注释,用三个单引号 ''' print("Hello, World!") dict1 = {'user': 'runoob', 'num': [1, 2, 3]} dict2 = dict1 # 浅拷贝: 引用对象 dict3 = dict1.copy() # 浅拷贝:深拷贝父对象(一级目录),子对象(二级目录)不拷贝,还是引用 # 修改 data 数据 dict1['user'] = 'root' #dict1['num'].remove(1) # 输出结果 print(dict1) print(dict2) print(dict3) thisset = set(("Google", "Runoob", "Taobao", "Facebook")) x = thisset.pop() print(x) print(thisset);
Python3