#-*-coding:utf-8-*- name=input('inputyourname:') age=int(input('inputyourage:')) job=input('inputyourjob:') msg=''' infomation of user%s: ---------------------------- Name:%s Age:%d Job:%s ---------End----------------- '''%(name,name,age,job) print(msg) #%s代表字符串 #%d代表插進去的必須是數字 #%f代表小數浮點 #int(input('inputyourage:'))把數據強制轉換成int模式 %s相同的結果,注意這樣做要開闢3個內存空間 name = 'liangml' print("my name is" + name + "and you ?") -------------------set小程序-------------------------- old_dict = { '#1': 8, '#2': 4, '#4': 2, } new_dict = { '#1': 4, '#2': 4, '#3': 2, } #應該是刪除哪幾個槽位 #應該更新哪幾個槽位 #應該增加哪幾個槽位 # old_keys = old_keys() # old_set = set(old_keys) new_set = set(new_dict.keys()) old_set = set(old_dict.keys()) remove_set = old_set.difference(new_set)#A中有B中沒有 add_set = new_set.difference(old_set)#更新元素 update_set = old_set.intersection(new_set)#合集 print(remove_set,add_set,update_set)
set集合
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.