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 中的一个错误 - 您是否尝试过没有它的程序?
推荐阅读
- javascript - Angular 6 - 服务中的 API Post 调用 - 更改为使用 XML
- rule-engine - 可以添加到剪辑规则引擎的最大事实数是多少?
- postgresql - 在 dockerized postgresql 中导入数据库
- javascript - 如何使用 JavaScript 或 JQuery 在 HTML 中删除表格内的特定跨度?
- laravel - Laravel 5.6 方法 Illuminate\Database\Query\Builder::createToken 不存在
- bots - 如何创建单击脚本的在线机器人?
- java - 选项卡切换冻结 (setAdapter)
- erlang - Erlang 开始日期和结束日期之间每天的日期范围间隔
- java - java.net.UnknownHostException 无法创建套接字。爪哇
- mongodb - 在 docker 容器中使用 MongoChef 和 mongodb