Thread View: pl.comp.programming
2 messages
2 total messages
Started by fir
Sun, 12 Apr 2020 12:54
inne pytanie z pythona
Author: fir
Date: Sun, 12 Apr 2020 12:54
Date: Sun, 12 Apr 2020 12:54
16 lines
1256 bytes
1256 bytes
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?
Re: inne pytanie z pythona
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads