python - Python上的“需要以下参数:操作”错误
问题描述
我是 Python 的初学者,很抱歉这个基本问题。(对不起我的英语)我尝试使用这个github 代码块进行 Profinet 通信。如果我这样调用 main.py:
python main.py -i discover
比我有这个错误:
usage: main.py [-h] -i INTERFACE
{discover,get-param,set-param,read,read-inm0-filter,read-inm0,read-inm1,write-inm1}
[target] [param] [value] [additional1] [additional2]
main.py: error: the following arguments are required: action
而不是我尝试使用这条线:
python server.py -i eth0
我有这个错误:
Traceback (most recent call last):
File "server.py", line 20, in <module>
s = ethernet_socket(args.i, 0x8892)
File "/home/name/Documents/profinet-master/util.py", line 25, in ethernet_socket
s = socket(AF_PACKET, SOCK_RAW)
File "/usr/lib/python3.6/socket.py", line 144, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
PermissionError: [Errno 1] Operation not permitted
那就是 ethernet_socket:
def ethernet_socket(interface, ethertype):
s = socket(AF_PACKET, SOCK_RAW)
s.bind((interface, ethertype))
return s
如何使用此代码或如何调用此 python 代码。请帮帮我谢谢。
解决方案
推荐阅读
- json - Laravel echo 以表单而不是 JSON 形式发送数据
- angular - 运行“ng build myAppName --prod”但没有 --prod 时,Angular“Ngx-Captcha”会出错
- post - 我无法使用以下 POST 代码获取我的 API 令牌
- kotlin - F# 相当于 Kotlin 的 ?。操作员
- sql - 如何编写查询以获取给定日期范围之间的特定日期记录?
- javascript - 按参数值对对象进行排序
- python - 烧瓶 send_file 没有打开文件
- soap - 数字签名的 xml 在编码后是否保留其签名?
- react-native - 即使在用户注销并关闭应用程序后如何在应用程序中存储数据。在本机反应
- react-native - 如何使用功能组件在 React Native 中验证电子邮件和密码?