I want to be able to add 'u' to a reference string variable. I need to do this because when I am in the for loop, I can only access the string using the variable name.
Is there any way to do this?
>>> word = 'blahblah' >>> list = ['blahblah', 'boy', 'cool'] >>> import marisa_trie >>> trie = marisa_trie.Trie(list) >>> word in trie Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Argument 'key' has incorrect type (expected unicode, got str) >>> 'blahblah' in trie Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Argument 'key' has incorrect type (expected unicode, got str) >>> u'blahblah' in trie True >>> u"blahblah" in trie True >>> u(word) in trie Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'u' is not defined >>> uword in trie Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'uword' is not defined >>> u+word in trie Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'u' is not defined >>> word.u in trie Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'str' object has no attribute 'u'
source share