Hướng dẫn python unicode is not defined - python unicode không được xác định

Tôi đang cố gắng sử dụng gói Python có tên BIDI. Trong một mô -đun trong gói này (thuật toán.

Đây là các dòng:

# utf-8 ? we need unicode
if isinstance(unicode_or_str, unicode):
    text = unicode_or_str
    decoded = False
else:
    text = unicode_or_str.decode(encoding)
    decoded = True

Và đây là thông báo lỗi:

Traceback (most recent call last):
  File "", line 1, in 
    bidi_text = get_display(reshaped_text)
  File "C:\Python33\lib\site-packages\python_bidi-0.3.4-py3.3.egg\bidi\algorithm.py",   line 602, in get_display
    if isinstance(unicode_or_str, unicode):
NameError: global name 'unicode' is not defined

Làm thế nào tôi nên viết lại phần này của mã để nó hoạt động trong Python3? Ngoài ra, nếu bất cứ ai đã sử dụng gói BIDI với Python 3, vui lòng cho tôi biết nếu họ đã tìm thấy vấn đề tương tự hay không. Tôi đánh giá cao sự giúp đỡ của bạn.

Có một câu hỏi về dự án này? Đăng ký một tài khoản GitHub miễn phí để mở một vấn đề và liên hệ với người bảo trì và cộng đồng của nó. Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Chọn tên người dùng Địa chỉ EmailPassword

Bằng cách nhấp vào Đăng ký đăng ký cho GitHub, bạn đồng ý với Điều khoản dịch vụ và tuyên bố quyền riêng tư của chúng tôi. Chúng tôi thỉnh thoảng gửi cho bạn các email liên quan đến tài khoản.

Đã có trên Github? đăng nhập vào tài khoản của bạn

Nhấn lỗi sau sau khi va vào 0,10.3

File "/opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/stravalib/client.py", line 1658, in __next__
    return self.next()
  File "/opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/stravalib/client.py", line 1664, in next
    self._fill_buffer()
  File "/opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/stravalib/client.py", line 1639, in _fill_buffer
    entities.append(self.entity.deserialize(raw, bind_client=self.bind_client))
  File "/opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/stravalib/model.py", line 135, in deserialize
    o.from_dict(v)
  File "/opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/stravalib/model.py", line 68, in from_dict
    setattr(self, k, v)
  File "/opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/stravalib/attributes.py", line 57, in __set__
    self.data[obj] = self.unmarshal(val)
  File "/opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/stravalib/attributes.py", line 237, in unmarshal
    if isinstance(v, str) or isinstance(v, unicode):
NameError: name 'unicode' is not defined

Là cách khắc phục lý tưởng ở đây để thay thế unicode bằng str?Điều đó sẽ phá vỡ sự hỗ trợ cho Python 2.7?Rất vui khi mở PR nếu nó có ý nghĩa.

Sandeep Patel

unread,

Ngày 14 tháng 8 năm 2018, 4:08:59 AM8/14/188/14/18

cho người dùng web2py

Hello,

 

Đã sửa nó ngay bây giờ trong thân cây.Cảm ơn đã báo cáo điều này.

Nhấn lỗi sau sau khi va vào 0,10.3

Là cách khắc phục lý tưởng ở đây để thay thế unicode bằng str?Điều đó sẽ phá vỡ sự hỗ trợ cho Python 2.7?Rất vui khi mở PR nếu nó có ý nghĩa.

Sandeep PatelNgày 14 tháng 8 năm 2018, 4:08:59 AM8/14/18
Điều này đã hoạt động & nbsp; với 2.16 và python3 nhưng trong 2.17.1 tôi gặp lỗi. Tên 'Unicode' không được định nghĩa

Tìm lại

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
Traceback (most recent call last):
File "C:\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "C:/web2py/applications/institute/controllers/plugin_ckeditor.py", line 72, in <module>
File "C:\web2py\gluon\globals.py", line 421, in <lambda>
self._caller = lambda f: f()
File "C:/web2py/applications/institute/controllers/plugin_ckeditor.py", line 9, in upload
mime_type) = current.plugin_ckeditor.handle_upload()
File "C:\web2py\applications\institute\modules\plugin_ckeditor.py", line 112, in handle_upload
else:
File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 1755, in store
dest_file = self.uploadfs.open(unicode(newfilename), 'wb')
NameError: name 'unicode' is not defined

Snapshot lỗi & nbsp;

NameError(name 'unicode' is not defined)

Cảm ơn

Sandeep

Massimo di Pierro

unread,

Ngày 3 tháng 9 năm 2018, 3:12:04 AM9/3/189/3/18

cho người dùng web2py

Đã sửa nó ngay bây giờ trong thân cây.Cảm ơn đã báo cáo điều này.