Python 3.4语法错误及修复方法

Python 3.4语法错误及修复方法,python,python-3.4,argument-unpacking,Python,Python 3.4,Argument Unpacking,虽然在Python 3.6上接受了以下行,但在Python 3.4上我得到了一个语法错误: struct.pack_into('q' * len(GeoFence_lat_list)*2,buff,264,*GeoFence_lat_list, *GeoFence_lon_list) 其中GeoFence_lon_list是一个数组,声明为: Geo_Fence_list = [] GeoFence_lat_list = [] GeoFence_lon_list = [] 下面是要查看的更

虽然在Python 3.6上接受了以下行,但在Python 3.4上我得到了一个语法错误:

struct.pack_into('q' * len(GeoFence_lat_list)*2,buff,264,*GeoFence_lat_list, *GeoFence_lon_list)
其中GeoFence_lon_list是一个数组,声明为:

Geo_Fence_list = []
GeoFence_lat_list = []

GeoFence_lon_list = []
下面是要查看的更多代码:

if (Polygon_available_size == 0):
    buff = ctypes.create_string_buffer(workzone_size)
    struct.pack_into('q' * 33, buff, 0, Speed_limit, Speed_Zone_lat, Speed_Zone_longi, Speed_Zone_heading_radians,
            Speed_Zone_ITIS_CODE, Speed_Zone_2_lat, Speed_Zone_2_longi, Speed_Zone_2_heading_radians, Speed_Zone_2_ITIS_CODE,G20_lat, G20_longi,
            G20_heading_radians, G20_ITIS_CODE,W20_lat, W20_longi, W20_heading_radians ,W20_ITIS_CODE,W21_5BR_lat,W21_5BR_longi, W21_5BR_heading_radians,
            W21_5BR_ITIS_CODE,W21_5AR_lat,W21_5AR_longi, W21_5AR_heading_radians, W21_5AR_ITIS_CODE,First_Taper_lat,First_Taper_longi,
            Last_Taper_lat, Last_Taper_longi, 2020, 2456,60, Polygon_available_size)
elif (int(Polygon_available_size) > 0):
    geo_fence_size = struct.calcsize('q' * len(GeoFence_lat_list)*2)
    #print("geo_fence_size", geo_fence_size)
    workzone_size = workzone_size + geo_fence_size
    buff = ctypes.create_string_buffer(workzone_size)
    struct.pack_into('q' * 33, buff, 0, Speed_limit, Speed_Zone_lat, Speed_Zone_longi, Speed_Zone_heading_radians,
            Speed_Zone_ITIS_CODE, Speed_Zone_2_lat, Speed_Zone_2_longi, Speed_Zone_2_heading_radians, Speed_Zone_2_ITIS_CODE,G20_lat, G20_longi,
            G20_heading_radians, G20_ITIS_CODE,W20_lat, W20_longi, W20_heading_radians ,W20_ITIS_CODE,W21_5BR_lat,W21_5BR_longi, W21_5BR_heading_radians,
            W21_5BR_ITIS_CODE,W21_5AR_lat,W21_5AR_longi, W21_5AR_heading_radians, W21_5AR_ITIS_CODE,First_Taper_lat,First_Taper_longi,
            Last_Taper_lat, Last_Taper_longi, 2020, 2456,60, Polygon_available_size)
    struct.pack_into('q', * len(GeoFence_lat_list)*2,buff,264,*GeoFence_lat_list, *GeoFence_lon_list)
    GeoFence_lat_list.clear()
    GeoFence_lon_list.clear()
packed_flag = 1

Python3.4只允许每次调用一个未打包的参数

您的原始代码只是使用多个解包将多个列表附加到字节缓冲区中。只需多次调用
struct.pack_into()
,并为每个零件设置适当的偏移量,就可以实现同样的效果

start = 264
struct.pack_into(str(len(GeoFence_lat_list)) + 'q', buff, start, *GeoFence_lat_list);
start += 8 * len(GeoFence_lat_list)
struct.pack_into(str(len(GeoFence_lon_list)) + 'q', buff, start, *GeoFence_lon_list);

您能提供完整的错误跟踪吗?请看,这是一年前为Python3.5.Python3.4实现的,如果可能的话,您应该升级。我运行的是OpenWRT for ARM处理器。很难升级到Python 3.6