Article View: pl.comp.programming
Article #216874Re: inne pytanie z pythona
From: fir
Date: Mon, 13 Apr 2020 18:50
Date: Mon, 13 Apr 2020 18:50
56 lines
2391 bytes
2391 bytes
W dniu niedziela, 12 kwietnia 2020 14:54:17 UTC+2 użytkownik fir napisał:
> chcialbym zrobic predefiniowane notatki
> tj na komende
>
> mnion zzz aa = costam costam codtsm
>
> minion zapisywal w pliku tekstowym
>
> zzz aa = costam costam codtsm
>
> a pozniej na komende
>
> minion zzz aa
> wypisywal
> costam costam codtsm
>
> jak takie cos zrobic w pythonie?
ok i found it
p = ircmsg.find(channel)
r = ircmsg.find('===')
if p!=-1 and r!=-1:
key = ircmsg[p+len(channel)+1:r]
value = ircmsg[r+1+1+1:]
say("przyjalem")
bot_memory[key]=value
save_bot_memory()
p = ircmsg.find(channel)
if p!=-1:
key = ircmsg[p+len(channel)+1:]
if key in bot_memory:
say(bot_memory[key])
where
import json
bot_memory = {'a': 'a',
'b': 'b',
'c': 'c'}
f = open("bot_memory.json", 'r')
bot_memory = json.load(f)
f.close()
def save_bot_memory():
j = json.dumps(bot_memory)
f = open("bot_memory.json","w")
f.write(j)
f.close()
return
i hope this is ok
Technical Details
Message-ID:
<49924478-35ff-41f9-bc2f-c554849b033a@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!goblin2!goblin3!goblin.stu.neva.ru!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mailReferences:
<f284c7e0-d824-4c1c-89e2-58c7fec24da5@googlegroups.com>Show Full Headers
Complete Article Headers
X-Received: by 2002:ad4:5244:: with SMTP id s4mr18484659qvq.88.1586803844599; Mon, 13 Apr 2020 11:50:44 -0700 (PDT) X-Received: by 2002:a37:e30d:: with SMTP id y13mr5711133qki.439.1586803842966; Mon, 13 Apr 2020 11:50:42 -0700 (PDT) Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!goblin2!goblin3!goblin.stu.neva.ru!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: pl.comp.programming Date: Mon, 13 Apr 2020 11:50:42 -0700 (PDT) In-Reply-To: <f284c7e0-d824-4c1c-89e2-58c7fec24da5@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.172; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN NNTP-Posting-Host: 5.172.255.172 References: <f284c7e0-d824-4c1c-89e2-58c7fec24da5@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <49924478-35ff-41f9-bc2f-c554849b033a@googlegroups.com> Subject: Re: inne pytanie z pythona From: fir <profesor.fir@gmail.com> Injection-Date: Mon, 13 Apr 2020 18:50:44 +0000 Lines: 56 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit