第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

自己寫的代碼

import ConfigParser

import os


class student_info(object):

? ? def __init__(self,recordfile):

? ? ? ? self.logfile=recordfile

? ? ? ? self.cfg=ConfigParser.ConfigParser()

? ? def cfg_load(self):

? ? ? ? self.cfg.read(self.logfile)

? ? def cfg_dump(self):

? ? ? ? for sec in self.cfg.sections():

? ? ? ? ? ? print sec

? ? ? ? ? ? print self.cfg.items(sec)

? ? def cfg_del_section(self,section):

? ? ? ? self.cfg.remove_section(section)

? ? def cfg_add_section(self,section):

? ? ? ? self.cfg.add_section(section)

? ? def cfg_add_item(self,section,option,value):

? ? ? ? self.cfg.set(section,option,value)

? ? def cfg_del_item(self,section,option):

? ? ? ? self.cfg.remove_option(section,option)

? ? def cfg_has_section(self,section):

? ? ? ? return self.cfg.has_section(section)

? ? def cfg_has_option(self,section,option):

? ? ? ? return self.cfg.has_option(section, option)

? ??

? ? def save(self):

? ? ? ? fg=open(self.logfile,'w')

? ? ? ? self.cfg.write(fg)

? ? ? ? fg.close()

if __name__=='__main__':

? ??

? ? filepath='D:\python\imooc.txt' ? ? ? ?

? ? student=student_info(filepath)

? ? student.cfg_load()

? ? student.cfg_dump()

? ??

? ? add_list=[('grade','math','99'),('grade','Chinese','100'),('userinfo','email','123@qq.com')]

? ? for add in add_list:

? ? ? ? if student.cfg_has_section(add[0]):

? ? ? ? ? ? print add[0]+'已經(jīng)存在'

? ? ? ? ? ? if student.cfg_has_option(add[0], add[1]):

? ? ? ? ? ? ? ? print add[0]+'中的'+add[1]+'已經(jīng)存在,現(xiàn)在將其刪除'

? ? ? ? ? ? ? ? student.cfg_del_item(add[0], add[1])

? ? ? ? ? ? else:

? ? ? ? ? ? ? ? student.cfg_add_item(add[0], add[1], add[2])?

? ? ? ? ? ? ? ? print '已在'+add[0]+'中'+'添加'+add[1]

? ? ? ? else:

? ? ? ? ? ? student.cfg_add_section(add[0])

? ? ? ? ? ? if student.cfg_has_option(add[0], add[1]):

? ? ? ? ? ? ? ? print add[0]+'中的'+add[1]+'已經(jīng)存在,現(xiàn)在將其刪除'

? ? ? ? ? ? ? ? student.cfg_del_item(add[0], add[1])

? ? ? ? ? ? else:

? ? ? ? ? ? ? ? student.cfg_add_item(add[0], add[1], add[2])

? ? ? ? ? ? ? ? print '已在'+add[0]+'中'+'添加'+add[1]

? ??

? ? student.save()

? ? student.cfg_dump()



正在回答

1 回答

O(∩_∩)O哈!

2 回復(fù) 有任何疑惑可以回復(fù)我~
#1

蘭陵蕭蕭笙

厲害了
2017-10-23 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

自己寫的代碼

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)