-1

I trying open page with Russian symbols.

webbrowser.open('https://www.google.com/?q=привет')

But I have this in browser: https://www.google.com/?q=??????

Halvor Holsten Strand
  • 19,829
  • 17
  • 83
  • 99
fudf
  • 119
  • 1
  • 8
  • it's ok. mozilla tab opened with (?q=привет) on my machine. just check if your computer or browser supports cyrillic symbols – marmeladze Apr 18 '15 at 18:50

1 Answers1

1

Use a unicode string.

webbrowser.open(u'https://www.google.com/?q=привет')

You'll probably also want to use UTF-8 encoding for your source file, so make sure your editor actually saves in UTF-8 and add this to the top of the program

# -*- coding: utf-8 -*-
doog abides
  • 2,270
  • 16
  • 13
  • I tried but I have this error: **UnicodeEncodeError: 'ascii' codec can't encode characters in position 47-50: ordinal not in range(128)** – fudf Apr 19 '15 at 10:10
  • Probably because you are doing something you didn't write in your example. Read [Unicode HOWTO](https://docs.python.org/2/howto/unicode.html#the-unicode-type) Suffice it to say that whatever you are trying to do, can be done in Unicode. You may have to encode your strings such as `u''.join(url, query).encode('utf-8')` – doog abides Apr 19 '15 at 18:08