python - 来自代码编辑器的 common.py 文件的断言错误

(请注意:我是 Python 的初学者)当我尝试输入我的 bssid 时,它给了我一个断言错误,它引用了我认为来自另一个名为 common.py 的代码文件的一部分使用我的代码编辑器 (thonny)。我该如何补救?

import os
import time

opsys = input("Are you using MacOS or Windows? ")

if (opsys.lower() == "windows"): 
    print("\n Alrighty, let me just open u your command prompt for you.") 
    time.sleep(0.5)
    os.system("start /B start cmd.exe @cmd /k netsh wlan show interfaces")
    time.sleep(0.25)
    bssid = input("\nNow paste in the set of numbers labelled BSSID: ")
    print("Thanks")

这是断言错误引用自 common.py 的语句:

def parse_message(msg_string: str) -> Record:
    # DataFrames may have nan
    # pylint: disable=unused-variable
    nan = float("nan")  # @UnusedVariable
    assert msg_string[0] == MESSAGE_MARKER
    return eval(msg_string[1:].encode("ASCII").decode("UTF-7"))

这是整个回溯错误:

Traceback (most recent call last):
  File "C:\Users\tjmon\Documents\Honors Comp Sci\Other Programs\Lab3.py", line 60, in <module>
    bssid = input("\nNow paste in the set of numbers labelled BSSID: ")
  File "C:\Users\tjmon\AppData\Local\Programs\Thonny\lib\site-packages\thonny\common.py", line 220, in parse_message
    assert msg_string[0] == MESSAGE_MARKER
AssertionError

最佳答案

所以在common.py它被引用为 MESSAGE_MARKER = "\x02",意思类似于“文本开始”

Oct  Dec Char  Hex  Key     Comments
\000   0  NUL  \x00  ^@ \0 (Null byte)
\001   1  SOH  \x01  ^A    (Start of heading)
\002   2  STX  \x02  ^B    (Start of text)

也许这只是 thonny 中的一个错误 - 您是否在没有它的情况下尝试了您的程序?

https://stackoverflow.com/questions/64452487/

相关文章:

reactjs - 无法查询类型 "x"上的字段 "y"

r - 以编程方式将 R Shiny 应用程序作为后台作业启动

react-native - 在 React Native 中的数组或对象内部时,i18n 无法正确

reactjs - 如何更改点击 react 的类(class)?

python - 为什么 patch.contains_point() 在检查点是否在多边形内时与

python-3.x - python 中的 sys.exit 给出一个 SystemExit 错误

apache-spark - 无法使用 Apache Hudi 编写非分区表

hyperledger-fabric - super 账本结构 2.0 : Chaincode co

javascript - 从 MapBox GL JS 中的聚类中排除某些功能

ios - 带有 iOS 14 设备的 Xcode 10 - 尝试与此设备通信时遇到错误。 (该服务