簡體   English   中英

struct.error:required參數不是整數

[英]struct.error: required argument is not an integer

我有以下python代碼:

velocity = 0
rotation = 0
vr = velocity + (rotation/2)
vl = velocity - (rotation/2)
cmd = struct.pack(">Bhh", 145, vr, vl)

我處理以下錯誤:

File "control.py", line 125, in __init__  
cmd = struct.pack(">Bhh", 145, vr, vl)  
struct.error: required argument is not an integer

您使用的格式正在傳入的參數格式不正確h格式表示存儲short ,而傳入的值(即vrvl )看起來像是double

考慮將它們轉換為int或使用">Bdd"格式。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM