Python and Unicode characters

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024
  • What is Unicode? How can we insert Unicode characters into strings? What's the difference between \x, \u, and \U? How can we insert characters with their names?
    In this video, I answer these and many other questions about Unicode and Python characters.
    The Jupyter notebook for this video is on GitHub, at github.com/reu....
    And don't forget my free, weekly "Better developers" newsletter at BetterDevelope...!

ความคิดเห็น • 16

  • @pauloalmeida4807
    @pauloalmeida4807 ปีที่แล้ว +2

    The only place where this is very well explained! Thumbs UP!

  • @JoshPaulie
    @JoshPaulie 2 ปีที่แล้ว +1

    That's a sub from me!! Great video. Every few seconds is another great tidbit

  • @elise254
    @elise254 ปีที่แล้ว +1

    love u reuven

  • @Kai_Ning
    @Kai_Ning 2 ปีที่แล้ว +1

    Counting on your fingers in base 16 is easier than in base 10.
    Where in base 10 you need both your hands, in base 16 you need one. Have your thumb point at each phalanges of the other 4 fingers and it's base 12, add your finger tips or nails and it's base 16... add both and its base 20. I'm pretty sure that mastering that when you're learning to count would help ease that infamous math allergy a lot of people get when they start to learn the fundamentals of algebra at 5/6yo as it can trivialize the simplest additions, substractions and divisions.

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว +3

      First: That's a great trick for working in base 16!
      Second: I was actually part of a famous math curriculum known as "New Math" in the 1970s that taught number bases to kids in elementary school. (We also learned modular arithmetic and set theory.) It is famous for being one of the greatest disasters in math education. It confused children (and teachers), and didn't improve their scores. Nerds like me thought it was super interesting and useful, and when I got to college, no one believed me when I said I had learned modular arithmetic in 4th grade. But as a general educational strategy, it was a massive failure. I tried to teach number bases to my own children, but it managed to both bore and confuse them. Oh, well.

    • @Kai_Ning
      @Kai_Ning 2 ปีที่แล้ว +1

      @@ReuvenLerner Wow, that second point is mind blowing. I would expect children to be more receptive to number bases math. Maybe that's just more intuitive to count on your finger in base 12/16 but that's it ?
      Anyway modular arithmetic in 4th grade... that's crazy! I learned that in my last year of high school and only because i had chosen the "math specialty" in an already scientific curriculum.

  • @MatthewThompson-g8f
    @MatthewThompson-g8f ปีที่แล้ว +1

    In my Python.kv File i wanted to show a button with a Symbol, but nothing works and it seems, that the kv-file is not connected with the imported library unicodedata. Also chr and /U"20103" does not work in a kivy *.kv file and i can use it only in the python main.py.
    Button:
    text: '\N{CJK UNIFIED IDEOGRAPH-4E2D}' # This doesn't work
    Do you have an idea?

    • @ReuvenLerner
      @ReuvenLerner  ปีที่แล้ว

      Sorry, I don't know anything about Kivy!

    • @365bee
      @365bee ปีที่แล้ว +1

      mybe you can use
      "\u4e2d"
      instead

  • @obed818
    @obed818 2 ปีที่แล้ว +1

    Hello Reuven, may i ask you something; if i define two string with the same content(a=«hello»,b=«hello»)
    , it will give me the same id for both, but not if there is a space in it, which is very weird as space is in the ascii table, i noticed when using foreign character the id is always different not as with Latin character.
    Ive noticed very weird behavior when experimenting with object id this week some real non-sense, i would be interested to read about it if you have something to recommend me, if there is some python implementation as i dont code in C. Thank you, have a great day

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว

      Take a look at this blog post I wrote, which explains the issue: lerner.co.il/2015/06/16/why-you-should-almost-never-use-is-in-python/

    • @obed818
      @obed818 2 ปีที่แล้ว +1

      @@ReuvenLerner thank you gonna read it!

  • @iiannRB
    @iiannRB 9 หลายเดือนก่อน

    hello, I would like to replace LEFT (and right) SINGLE QUOTATION MARK ‘ ’ by APOSTROPHE ' in python. Also RIGHT DOUBLE QUOTATION MARK “ ”(and left) by QUOTATION MARK " . Anybody knows how please? I want to write them to text file from imported request.