小编Enn*_*per的帖子

Scapy:如何在现有数据包中插入新层(802.1q)?

我有一个数据包转储,并希望向数据包注入vlan标记(802.1q标头).
怎么做?

python scapy vlan

5
推荐指数
1
解决办法
5829
查看次数

如何在使用h5py高级接口时设置缓存设置?

我正在尝试增加我的HDF5文件的缓存大小,但它似乎没有工作.这就是我所拥有的:

import h5py

with h5py.File("test.h5", 'w') as fid:
        # cache settings of file
        cacheSettings = list(fid.id.get_access_plist().get_cache())
        print cacheSettings
        # increase cache
        cacheSettings[2] = int(5 * cacheSettings[2])
        print cacheSettings
        # read cache settings from file
        fid.id.get_access_plist().set_cache(*cacheSettings)
        print fid.id.get_access_plist().get_cache()
Run Code Online (Sandbox Code Playgroud)

这是输出:

[0, 521, 1048576, 0.75]
[0, 521, 5242880, 0.75]
(0, 521, 1048576, 0.75)
Run Code Online (Sandbox Code Playgroud)

知道为什么阅读有效,但设置没有?
关闭并重新打开文件似乎也没有帮助.

python h5py

4
推荐指数
2
解决办法
2263
查看次数

使用变量进行切片时如何使用单冒号?

我想使用变量来存储切片表达式.这是我尝试的:

    if variable is not None:
        var = variable
    elif self.__filter is not None:
        var = self.__filter
    else:
        # this doesn't work, : alone understandably gives a syntax error
        var = ':'
Run Code Online (Sandbox Code Playgroud)

然后在这里使用var:

return stuff[var]
Run Code Online (Sandbox Code Playgroud)

我想这样做是为了在我的代码中获得更好的结构.另一种方法是根据大小写返回这个表达式:

return stuff[variable]
return stuff[self.__filter]
return stuff[:]
Run Code Online (Sandbox Code Playgroud)

提出例外: ValueError: invalid literal for int() with base 10

有没有办法将冒号分配给var,因此它可以用于切片表达式(转义或类似的东西)或者我必须使用var = slice(0, self.getNumberOfVariables())

PS:我在询问前做了搜索,但没有找到这样的东西.对不起,如果我错过了重复.

python slice

1
推荐指数
2
解决办法
721
查看次数

标签 统计

python ×3

h5py ×1

scapy ×1

slice ×1

vlan ×1