bacnet_扫描输出csv文件错误类型错误:需要类似字节的对象,而不是“str”

2024-10-01 05:01:27 发布

您现在位置:Python中文网/ 问答频道 /正文

运行bacnet_scan.py时,它如下所示:

(volttron) (base) bartlino@bartlino-Latitude-E5530-non-vPro:~/Desktop/volttron/scripts/bacnet$ python bacnet_scan.py

Device Address        = <Address 192.168.0.190>
Device Id             = 0
maxAPDULengthAccepted = 1476
segmentationSupported = noSegmentation
vendorID              = 245

Device Address        = <Address 192.168.0.102>
Device Id             = 3056183
maxAPDULengthAccepted = 1024
segmentationSupported = segmentedBoth
vendorID              = 842

Device Address        = <RemoteStation 12345:2>
Device Id             = 201201
maxAPDULengthAccepted = 286
segmentationSupported = noSegmentation
vendorID              = 11

正在尝试使用python bacnet_scan.py --csv-out ~/Desktop/volttron/configs/test_mult.csv添加csv文件输出

我得到一个错误:

Traceback (most recent call last):
  File "bacnet_scan.py", line 203, in <module>
    this_csv_file.writeheader()
  File "/home/bartlino/anaconda3/lib/python3.8/csv.py", line 143, in writeheader
    return self.writerow(header)
  File "/home/bartlino/anaconda3/lib/python3.8/csv.py", line 154, in writerow
    return self.writer.writerow(self._dict_to_list(rowdict))
TypeError: a bytes-like object is required, not 'str'

有什么建议吗


Tags: csvinpyidscanaddressdeviceline
1条回答
网友
1楼 · 发布于 2024-10-01 05:01:27

如果您不是使用最新的开发分支,我建议您首先尝试,因为有一个PR accepted after the 8.0 release修复了此脚本输出中与字节与字符串相关的问题。我也不确定它们是如何交互的,但您当前似乎激活了两个虚拟环境,这可能会干扰一些版本控制。。。因为它的Python3.8是你的Python,我怀疑这一点,但它需要考虑。

相关问题 更多 >