Open FredyVia opened 2 years ago
已收到,谢谢|
还有个小问题,不知道是不是python版本问题(使用3.9.10 和 3.9.7均有该问题):
bind_nic()
函数中struct.pack('256s', ifname[:15])
报错
Traceback (most recent call last):
File "/root/wan1.py", line 66, in <module>
bind_ip = bind_nic()
File "/root/wan1.py", line 57, in bind_nic
return get_ip_address(nic_name)
File "/root/wan1.py", line 55, in get_ip_address
struct.pack('256s', ifname[:15])
struct.error: argument for 's' must be a bytes object
改为struct.pack('256s', ifname[:15].encode('utf-8'))
后正常
finally里面的return覆盖原有的return ref:python finally 问题