这是python 中的字符?

发布于 2025-01-10 13:50:53 字数 554 浏览 4 评论 0原文

我通过 python 套接字与物理设备进行通信。我有点习惯这样做,但不是专家。 我发送给设备的命令通常可以在设备的手册中找到。通常,命令以 CR 或 LF (或两者)结尾,并且当我执行以下操作时效果很好:

mysocket.send((command+"\r\n").encode())

将“\r\n”作为 CRLF (尽管作为 这个答案说,CRLF和\r\n不完全相同)

我发现一个设备需要用 INQUIRY char 结束命令,根据手册,其十六进制代码等于 ASCII 表中的 05(手册还说 CR 和 LF 的十六进制代码是 0D 和 0A,所以我认为它是正确的)。

虽然我已经查看了 ASCII 表,但它没有与此相关的字符,甚至没有 CR 和 LF。不同语言中用于这些含义的字符是否有不同的表?我应该在编码字符串中放入什么来匹配 python 中的含义?

Im communicating with physical equipments via python socket. Im kinda used to doing it, but not an expert.
The commands which i send to the equipments are usually found in the equipment's manuals. Usually, commands end with CR or LF (or both) and work well when i do something like:

mysocket.send((command+"\r\n").encode())

With "\r\n" acting as CRLF (although as this answer says, CRLF and \r\n are not exactely the same thing)

I found an equipment which needs to end commands with ENQUIRY char which, according to the manual, has hexadecimal code equal to 05 in the ASCII table (the manual also says the hexadecimal code of CR and LF which are 0D and 0A, so i think its correct).

Although i have looked into the ASCII table, it has no char related to this or even CR and LF. Is there a different table for chars used with these meanings in different languages? What should i put inside an encoded string to match the meaning in python?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ら栖息 2025-01-17 13:50:53

您可以使用它

chr(charCode)

来检索任何给定 ASCII 数字的正确字符。

https://docs.python.org/3/library/functions.html#字符

You can use

chr(charCode)

to retrieve the correct character for any given ASCII number.

https://docs.python.org/3/library/functions.html#chr

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文