使用pybricks-micropython 运行此命令以获取随机端口号,在CPython下工作。 import random
port = random.randint(50000,50999) 生成一个数字,只是它几乎不是随机的。每次我运行脚本时,它都是相同的数字。我猜MicroPython可能需要更多的东西? 我错过了什么?
我想运行我的C++代码,而不是micropython。
为此,我提到了这个包装器。
将所需的包装文件上载到板上,并试图运行
#include <micropython-wrap-master/functionwrapper.h>
//function we want to call from within a MicroPython script
std::vector< std::string > FunctionToBeCalled ( std::vector< std::string > vec )
{
for( auto& v : ve
在使用MicroPython时,我最近从python复制了"toBits()“函数。我的代码是:
def tobits(s):
bits = ""
for c in s:
bits2 = ''.join(format(ord(i), '08b') for i in c)
bits = bits + bits2
return bits
但是,在使用此函数时,我得到了一个错误:"NameError: name 'format‘未定义“
我假设MicroPython中没有“格
我试图使用.asm MicroPython在sd卡中读取带有和.py扩展名的所有文件。
我在中检查了答案,但它们不适用于MicroPython。
MicroPython没有glob或pathlib,在使用os库时尝试以下代码:
for file in os.listdir('/sd'):
filename = os.fsdecode(file)
if filename.endswith(".asm") or filename.endswith(".py"):
print(filename)
我想使用micropython运行我的C++程序,它运行在esp-32板上。现在我想使用micropython运行它。为此,我指的是
这个包装纸。
我创建了foo.cpp和test.py
#include <micropython-wrap-master/functionwrapper.h>
//function we want to call from within a MicroPython script
std::vector< std::string > FunctionToBeCalled ( std::vector< std::string >