问题标签 [ord]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
57 浏览

python - Python 二进制到多十六进制

我正在尝试读取二进制文件并返回例如“ffffff”一系列 6 个十六进制代码。这有意义吗?我的代码(下面)只返回一个 2 的列表,所以它看起来像“ff”

我特别想让这个回报像

不喜欢

任何帮助将不胜感激。

0 投票
1 回答
793 浏览

unicode - 如何在 elisp 中获取字符的代码点(以及其他方式)?

我很惊讶不能在 elisp 手册或 SO 中找到它。我只想要许多语言的 chr() 和 ord() 或类似的等效项:在实际字符及其(unicode)代码点值之间进行转换。

Emacs Lisp:getting ascii value of character解释了 elisp,char 只是的代码点。但是,如果我需要将该 char~int 表示为一系列 ASCII 十进制数字怎么办?

例如,如果我想在缓冲区中生成一个显示等价的可读表?

谢谢!

0 投票
1 回答
290 浏览

sphinx - 狮身人面像似乎强制对 ID 下订单?

我在索引 ( weight) 中添加了一个新字段,它是我想要排序的基于整数的值。

我将它添加到选择中并将其调用为sql_attr_uint

当我在查询中调用它时,它会显示出来。但是,当我尝试对其进行排序时,我会遇到奇怪的行为。它总是按记录 ID 排序。所以Order on ID等同于Order on Weight

我已经非常彻底地检查了索引,但找不到原因,狮身人面像会以某种方式自动对记录 ID 进行排序吗?

我知道细节相当稀疏,但我希望在要求任何人进一步深入研究之前,我缺少一些基本的解释。

作为更新:我不相信 ID 字段排序已被“强加”在索引上,因为我可以按 # 其他字段排序,包括整数和文本,并且结果的返回与 ID 值无关(例如,按姓氏排序 Record #100Adams将在 Record #1 之前Wyatt

然而,无论是 asc 还是 desc ,orderingWeight总是返回与 ordering 相同的 order 。ID关于字段或索引不存在或不可排序的错误,不忽略订单请求(descasc工作)它只是忽略该特定字段值并使用 ID 代替。

进一步更新:权重值通过连接到由 sphinx 索引的主表以下列方式进行索引:

一旦对两者进行索引排序idvalue_Weight返回相同的排序,而权重和 ID 是不相关的。

0 投票
1 回答
6957 浏览

python - TypeError: ord() expected string of length 1, but int found

I try to implement a AES algorithm in python 3.While implementing this I found an error in ord() function.I just try to convert the code from python 2.3 to python 3.How can I fix the error? My code line is :

Thanks in advance

0 投票
2 回答
9256 浏览

python - 如何在 Python 中获取 ASCII 西里尔字符代码?

ord()返回 unicode 代码,我需要 ascii。

我需要ASCII。如何得到它?(以下)

在此处输入图像描述

0 投票
1 回答
974 浏览

python - Python converting letter to ASCII using ord

I am trying to do some coursework but I have hit a wall. I am trying to write a function that takes a letter and a digit as the inputs, and returns the letter shifted key positions to the right in the alphabet. This is what I have so far:

The problem is the letter=ord(letter) as I keep getting TypeError: ord() expected string of length 1, but list found. I have tried different variations. I need to convert the input 'letter' into ASCII.

0 投票
3 回答
59 浏览

python - 我怎样才能让它更短更好?

我有一个关于循环中字符串的分配,我需要找出输入中有多少 (a,e,i,o,u) 。我已经完成了,但我认为它太长了。我想让它更短,但我不知道怎么做。

这是我的代码:

0 投票
2 回答
526 浏览

python - python和ruby中的不同编码

我正在尝试在 Python 中模仿 Rubys .bytesize 字符串函数。但是我遇到了某些字符的问题,例如“'”

在红宝石中

在 Python 中

两种语言的编码有什么区别?这与提供类似对比结果的不同在线转换器进一步混淆。例如 - http://www.unit-conversion.info/texttools/ascii/产生与 Ruby 相同的结果,而https://www.branah.com/ascii-converter产生与 Python 相同的结果。

0 投票
1 回答
809 浏览

python - 如何将转义序列传递给 python 的 ord() 函数?

我正在使用 Python 3。我还在脚本中使用了 ord() 函数。如果我ord('\xff')在控制台中输入它会返回255

有没有办法在不获取的情况下将\xff(存储在变量中)插入到ord()函数中

如何ord('\xff')工作?ord() 不读取字符串?那它在读什么?

0 投票
3 回答
24 浏览

python - 如何在密码程序(python3)中返回字符数组

我在输入例如“a”时编写代码,他返回“h”。但是,如果我想返回字符数组,例如如果输入“aa”以返回“hh”,我该如何让它工作?