cPickle的问题?
时间:2011-04-27
来源:互联网
import sys
import time
try:
import cPickle as p
except:
import Pickele as p
class contact:
def __init__(self,name,phone):
self.name=name
self.phone=phone
list=[self.name,self.phone]
listdicts={}
listdicts['name']='phone'
cont="ms.log"
f=file(cont,"a+")
p.dump(listdicts,f)
f.close()
listdicts.clear()
def inputinfo():
while True:
name=raw_input("Enter name:")
phone=raw_input("Enter phone number:")
forsure=raw_input("Are you sure?(Y/N)")
if forsure=="y":
contact(name,phone)
sys.exit()
elif forsure=="n":
break
else:
continue
def searchinfo():
name=raw_inpout("Enter name for seach:")
cont=file("ms.log")
listdicts={}
i=1
while True:
try:
listdicts.update(p.load(cont))
print "load %s times"%i
print listdicts
i+=1
except EOFError:
break
cont.close()
print listdicts
print "you want search is %s"%name
if name in listdicts:
print listdicts['name']
else:
print "No found the name"
sys.exit()
没报错,但运行没反映
import time
try:
import cPickle as p
except:
import Pickele as p
class contact:
def __init__(self,name,phone):
self.name=name
self.phone=phone
list=[self.name,self.phone]
listdicts={}
listdicts['name']='phone'
cont="ms.log"
f=file(cont,"a+")
p.dump(listdicts,f)
f.close()
listdicts.clear()
def inputinfo():
while True:
name=raw_input("Enter name:")
phone=raw_input("Enter phone number:")
forsure=raw_input("Are you sure?(Y/N)")
if forsure=="y":
contact(name,phone)
sys.exit()
elif forsure=="n":
break
else:
continue
def searchinfo():
name=raw_inpout("Enter name for seach:")
cont=file("ms.log")
listdicts={}
i=1
while True:
try:
listdicts.update(p.load(cont))
print "load %s times"%i
print listdicts
i+=1
except EOFError:
break
cont.close()
print listdicts
print "you want search is %s"%name
if name in listdicts:
print listdicts['name']
else:
print "No found the name"
sys.exit()
没报错,但运行没反映
作者: xuzhijian17 发布时间: 2011-04-27
1,LZ没缩进。。
2,没看到调用的方法,如果你就这样写了运行,没反应是肯定滴。。把调用方法写出来。
把缩进搞好了再让人看吧。。
2,没看到调用的方法,如果你就这样写了运行,没反应是肯定滴。。把调用方法写出来。
把缩进搞好了再让人看吧。。
作者: amu9900 发布时间: 2011-04-27
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28