Friday, May 28, 2010

Writing Polish text into a file using Python

i need to write some polish text into a new file, so I have tried:

myLines = somePolishText
file = open('myText.txt', 'w')
file.writelines(myLines)


at this point, I've got an error like this:
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0119' in position 29: ordinal not in range(128)


After lots of recharch and findings, I have change the same code like this:

import codecs

myLines = somePolishText
file = codecs.open('myText.txt', 'w', 'utf-8')
file.writelines(myLines)


and its works for me pritty well.

Thanks
Sakib

Thursday, May 27, 2010

Problem with changing mac address in Ubuntu, solved...

I was trying to change the mac address in network, but when I add new mac address to a connection, it was creating another connection and use it.
Then I do this:

In Terminal:

sudo gedit /etc/network/interfaces

It will bring up a document, I just added few lines, so it looked like this:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
hwaddress ether 02:01:02:03:04:01


then i've save and close.
then in the terminal, i've run this commands:

sudo /etc/init.d/networking restart
ifconfig


And that's it. It worked for me.

Thnaks,
Sakib