1 11 11

: python 2 3

  1. #1
    Ubuntu
    Unity

    Apr 2009
    685
    1,028
    263 148

    python 2 3



    python 2 3 ..

    python .. python3 python2

    ! .. python2 python3 .. !

    .. ..

    python2 utf8 :
    :
    if sys.version_info < (3, 0):
      reload(sys).setdefaultencoding('UTF8')
    python3 latin1 utf8 ( python2):
    :
    string.encode('latin1').decode('utf8')
    python2 ( п)

    utf8 python3

    .. bottle

    bottle utf8

    python3
    :
    request.POST.uname -  utf8
    request.POST['uname'] -  latin1
    python2
    :
     request.POST.uname -  latin1
    request.POST['uname'] -  utf8
    python2:
    :
    if sys.version_info < (3, 0):
      reload(sys).setdefaultencoding('UTF8')
    request bottle
    { }

  2. :


  3. #2
    .: :.
    Fedora
    XFCE

    Feb 2008
    798
    5,695
    889 392
    1


    python3


    PHP:
    request.forms.get('name')

    or

    request.forms.getunicode('name'



    { }
    http://www.ipc.org.kw


    1-

    2-

    3-

    4-

    - 44 1399/ 1978 .




  4. 2 :


  5. #3
    Ubuntu
    Unity

    Apr 2009
    685
    1,028
    263 148

    python3 python2

    python3


    :
      request.forms.get('name')
    bottle

    cookie utf8

    :
    request.POST.name
    ( )
    Changing the Default Encoding

    https://bottlepy.org/docs/dev/tutorial.html
    :
    from bottle import response, route, run
    @route('/iso')
    def get_iso():
        response.charset = 'ISO-8859-15'
        return u'This will be sent with ISO-8859-15 encoding.'
    
    @route('/latin9')
    def get_latin():
        response.content_type = 'text/html; charset=latin9'
        return u'ISO-8859-15 is also known as latin9.'
    
    run(reloader=True, debug=True)
    .. .. route !
    { }

  6. #4
    .: :.
    Fedora
    XFCE

    Feb 2008
    798
    5,695
    889 392
    1

    python3 python2

    python3
    python3
    python3


    bottlepy
    PHP:
    request.forms.getunicode('name'

    cookie utf8
    str :

    PHP:
      
    response
    .set_cookie('name','mohhamed',secret='!@#$#@',max_age=timedelta(days=1)')
     
    request.get_cookie('
    name',secret='!@#$#@')
       secret  


    bottlepy


    { }
    http://www.ipc.org.kw


    1-

    2-

    3-

    4-

    - 44 1399/ 1978 .




  7. :


  8. #5
    Ubuntu
    Unity

    Apr 2009
    685
    1,028
    263 148

    ..


    :
     response.set_cookie('UNAME', request.POST.uname)
    request.POST.uname .. " "

    :
    :
     request.get_cookie(key, '')
    ( utf8 latin1 .. latin1 bottle :
    :
     out = [(k, v.encode('utf8').decode('latin1')) for (k, v) in out]
    utf8 latin1



    sqlite3 python
    commit SELECT UPDATE, INSERT, DELETE ...

    SQLAlchemy
    { }

  9. #6
    .: :.
    Fedora
    XFCE

    Feb 2008
    798
    5,695
    889 392
    1

    ..
    PHP:
    uname=request.forms.getunicode ('uname')
    uname=uname.encode('utf-8')
    response.set_cookie ('UNAME'uname)
     
    uname
    =request.get_cookie('uname')
    uname=uname.decode('utf-8'

    commit
    SQLAlchemy


    { }
    http://www.ipc.org.kw


    1-

    2-

    3-

    4-

    - 44 1399/ 1978 .




  10. :


  11. #7
    .: :.
    Ubuntu 16.04 LTS
    MATE

    Sep 2006
    650
    138
    382 195

    import six

    Th1nk bad ... D0 g00d


  12. :


  13. #8
    Ubuntu
    Unity

    Apr 2009
    685
    1,028
    263 148

    ...

    { }

  14. #9
    .: :.
    Fedora
    XFCE

    Feb 2008
    798
    5,695
    889 392
    1

    PHP:
     a=''>>> type(a)<class 'str'>>>> b=a.encode('utf-8')>>> bb'\xd9\x85\xd8\xac\xd9\x84\xd8\xa7\xd8\xaf'>>> type(b)<class 'bytes'>>>>c='mjlad'
    >>>c.encode('utf-8')
    b'mjlad' 
    bytes


    { }
    http://www.ipc.org.kw


    1-

    2-

    3-

    4-

    - 44 1399/ 1978 .




  15. :


  16. #10
    .: :.
    Fedora
    XFCE

    Feb 2008
    798
    5,695
    889 392
    1




    { }
    http://www.ipc.org.kw


    1-

    2-

    3-

    4-

    - 44 1399/ 1978 .




  17. :


  18. #11
    .: :.
    Ubuntu 16.04 LTS
    MATE

    Sep 2006
    650
    138
    382 195

    unicode

    Th1nk bad ... D0 g00d


  19. :


: 1 (0 1 )