0

次のコードがあります。

# -*- coding: utf-8 -*-
import splinter
import urllib

browser = splinter.Browser('firefox')

miss = ("rúin",)

for i in miss:
    browser.visit(link)
    browser.fill('word', i)

エラーが表示されます:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

この問題を解決するにはどうすればよいですか?

4

1 に答える 1

1

Use an actual unicode value:

miss = (u"rúin",)

Note the u before the string literal.

Python otherwise will try to coerce the bytestring to unicode implicitly, using the default codec (ASCII).

于 2013-12-29T16:58:19.003 に答える