【问题标题】:"-" en dash giving different ascii values"-" en dash 给出不同的 ascii 值
【发布时间】:2020-01-21 11:01:10
【问题描述】:

我读到 endash 不是 ASCII 但是,下面的代码显示:

print(ord('-'))
>>>45

那么,到底是不是ASCII?

其次,当我再次在 Ascii 中查找“endash”时,“-”ASCII 码显示为 8211。

 for c in "wireless enhancements – extra costs":
    print(c , ord(c))

– 8211

我无法理解这种结束语。请解释

【问题讨论】:

  • 嗯,第一个是减号,第二个是破折号。破折号稍宽,不构成 ascii 的一部分。
  • 大概第一个是连字符或减号-(ASCII),而第二个是endash(Unicode)
  • 谢谢。约翰C,杰米道奇

标签: python python-3.x string ascii unicode-string


【解决方案1】:

下面代码中的-字符是'U+002D HYPHEN-MINUS'

print(ord('-'))

下面代码中的字符是'U+2013 EN DASH'

for c in "wireless enhancements – extra costs":

您可以使用本站自行检查:https://www.babelstone.co.uk/Unicode/whatisit.html

【讨论】:

  • 谢谢@ruohola。另外,在windows中,我们没有办法直接写endash。
  • @PayalBhatia 在某些文字处理器中,在键盘上输入 -(连字符)会在文档中插入一个 endash。
猜你喜欢
  • 2019-04-23
  • 2016-06-06
  • 1970-01-01
  • 2017-05-29
  • 1970-01-01
  • 2020-01-10
  • 2011-04-30
  • 2019-04-22
  • 2019-07-17
相关资源
最近更新 更多