Hi.
I have a problem. I am meking a program which amkes .txt documents. The problem is a have to insert words, which have charecters like this: č,š,ž. You can find them in UTF-8 cade, but Idel givs me back this message:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "G:\pomozni3.py", line 305, in koncaj_delo
f.writelines(vnos)
TypeError: writelines() argument must be a sequence of strings
or:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "G:\pomozni3.py", line 242, in potrditev
f.write(ime1)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0160' in position 0: ordinal not in range(128)
The function in which this apper looks like this:
def koncaj_delo(self):
ime="%s"%self.listbox_partnerji.get(self.indeks_partner)
ime1=''
for i in range(len(ime)-1):
ime1=ime1+ime[i]
ime_datoteke=ime1+' '+self.now.strftime("%m.%Y")+'.txt'
f=open(ime_datoteke, 'a+')
naslov=f.readline()
f.close()
vnos="%s %s %s %s %s\n"%(self.datum_opravila.get(), self.cas_opravila.get(), self.time3, self.listbox_opravilo.get(self.indeks_opravilo), self.listbox_uporabnik.get(self.indeks_uporabik))
if naslov!=ime:
f=open(ime_datoteke, 'a+')
f.writelines(ime)
f.writelines(vnos)
f.close()
else:
f=open(ime_datoteke, 'a+')
f.writelines(vnos)
f.close()
Thenks for help.