Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]python中finally问题 #375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

FredyVia
Copy link

finally里面的return覆盖原有的return
ref:python finally 问题

@dadavinson

This comment was marked as duplicate.

@FredyVia
Copy link
Author

还有个小问题,不知道是不是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'))后正常

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants