Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
375 views
in Technique[技术] by (71.8m points)

Why am i getting invalid syntax using curl in pycharm?

I am brand new at Python an i'm trying to followa basic programming cours from ciso/github. i am following some instructons verbatim, literally a cu n paste from some sample code, yet i still get syntax errors . can somebody telly me what is going wrong please?` her is my code

curl -k -x "https://10.85.116.30:443/restconf/data/Cisco-IOS-XE-native:native/logging/monitor/severity" 
-H 'Accept: application/yang-data+json' 
-u 'admin:admin'
  File "<input>", line 1
    curl -k -x "https://10.85.116.30:443/restconf/data/Cisco-IOS-XE-native:native/logging/monitor/severity" 
               ^
SyntaxError: invalid syntax
            ^
question from:https://stackoverflow.com/questions/65650833/why-am-i-getting-invalid-syntax-using-curl-in-pycharm

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You wrote a bash script. Not a python. Hence the syntax error. curl is a CLI program. Take a look on how to run CMD/CLI commands through python. Or use the ‘requests’ module within python to send an HTTP request.

Request module - https://requests.readthedocs.io/en/master/

Executing CLI in Python - How to execute a program or call a system command from Python?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...