最近看《a byte of python》自學python,看完全書之後書最後面有習題,說如果做出來這個程式就可以自稱為python程式設計師^ ^
然後我就隨便寫了一下,發現bug真多,哈哈,小程式,**也帖出來吧
1#com.address2#
filename: __init__.py3#
先建乙個字典,來存通訊錄資料
4class
person:
5 infomation = 67
#print person.infomation
1#com.address2#
filename: zsgc_address34
from
__init__
import
person
5import
cpickle as p
67 numberfile = '
numberfile.data
'8 f =file(numberfile)9#
choose
10while
true:
11 choose = str(raw_input('''
what do u what?
12enter '1' read
13enter '2' add
14enter '3' del
15enter 'exit' out
''')) 16#
read
17if choose == '1'
:18if person.infomation =={}:
19print
'nothing here, u can add the first address'20
else
:21 f = file(numberfile, 'r'
)22 person.infomation =p.load(f)
23for name, number in
person.infomation.items():
24print
'name is %s ,number is %s
' %(name, number)
2526
#write
27elif choose == '2'
:28#input
29 add_name = str(raw_input('''
input the add_name :
'''))
30 add_number = str(raw_input('''
input the add_number:
'''))
31 person.infomation[add_name] =add_number32#
cpickle to data
33 f = file(numberfile, 'w'
)34p.dump(person.infomation, f)
35print
'newone name is %s ,number is %s
' %(add_name, add_number)
3637
#delete
38elif choose == '3'
:39if person.infomation =={}:
40print
'nothing here to be delete'41
continue
42else
:43 f = file(numberfile, 'w'
)44 del_name = str(raw_input('''
input the person's name
45that u gonna to del :
'''))
46del
person.infomation[del_name]
47p.dump(person.infomation, f)
48print
'delete %s ok!
' %del_name
4950
#out
51elif choose == '
exit':
52print
'byebyebyebyebyebyebye'53
f.close()
54break
5556
#others
57elif len(choose) ==0:
58print
'please enter something'59
60else:61
'please make a choose'62
continue
63
C語言通訊錄小程式
include include define max person info size 300 實現乙個通訊錄程式,完成聯絡人資訊的儲存 1 新增 2 刪除 3 修改記錄 4 查詢記錄 5 列印全部記錄 6 排序記錄 7 清空全部記錄 管理 1 把基本資訊抽象並描述出來 結構體 2 需要管理很多資料...
通訊錄小感想(1)
通訊錄小感想 今天算是完成了通訊錄的小專案,感覺自己還有不少不足。通過做完這乙個小專案,感覺運用到了許多知識點,也從中感受到了完成的成就感 雖然還比較小 所以今後我會更加努力去學習 改進,然後提公升自己。下面是我c程式中遇到的各種問題 一 if的條件判斷 經常漏 二 全域性變數和區域性變數的使用 三...
通訊錄源程式分析
1 linkmanmodels類庫 1 linkmanmodels類庫,首先建立這樣乙個類庫,包括兩個檔案,person.cs和friendgroup.cs,分別定義了類person 僅包括有關 人 的屬性 和類friendgroup 有關 組 的屬性 2 model定義業務實體,它是傳遞各種資料的...