温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何设置python脚本运行参数

发布时间:2021-05-22 17:57:27 来源:亿速云 阅读:633 作者:Leah 栏目:开发技术

本篇文章给大家分享的是有关如何设置python脚本运行参数,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

D:\Python2.7\python.exe "D:/Django project/DjangoProject1/manage.py"
 
Type 'manage.py help <subcommand>' for help on a specific subcommand.
 
Available subcommands:
 
[auth]
 changepassword
 createsuperuser
 
[django]
 check
 compilemessages
 createcachetable
 dbshell
 diffsettings
 dumpdata
 flush
 inspectdb
 loaddata
 makemessages
 makemigrations
 migrate
 sendtestemail
 shell
 showmigrations
 sqlflush
 sqlmigrate
 sqlsequencereset
 squashmigrations
 startapp
 startproject
 test
 testserver
 
[sessions]
 clearsessions
 
[staticfiles]
 collectstatic
 findstatic
 runserver
 
Process finished with exit code 0

没有显示监听端口,因为它本身缺少参数

1、常用的命令行设置参数的方法

D:\Django project\DjangoProject1>python manage.py runserver 0.0.0.0:8000

在manage.py脚本的根目录下运行cmd,输入python manage.py + 参数,以下是运行结果

Performing system checks...
 
System check identified no issues (0 silenced).
 
You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
April 11, 2017 - 13:26:13
Django version 1.10.6, using settings 'DjangoProject1.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CTRL-BREAK.
[11/Apr/2017 13:27:16] "GET / HTTP/1.1" 200 1767
Not Found: /favicon.ico
[11/Apr/2017 13:27:16] "GET /favicon.ico HTTP/1.1" 404 1944
Not Found: /favicon.ico
[11/Apr/2017 13:27:16] "GET /favicon.ico HTTP/1.1" 404 1944

成功监听到了8000端口

2、在pycharm中设置运行参数

run --> Edit Configurations -->Scrip parameters

如何设置python脚本运行参数

如何设置python脚本运行参数

设置好之后运行

D:\Python2.7\python.exe "D:/Django project/DjangoProject1/manage.py" runserver 0.0.0.0:8000
Performing system checks...
 
System check identified no issues (0 silenced).
 
You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
April 11, 2017 - 14:07:30
Django version 1.10.6, using settings 'DjangoProject1.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CTRL-BREAK.

成功监听8000端口。

Python主要用来做什么

Python主要应用于:1、Web开发;2、数据科学研究;3、网络爬虫;4、嵌入式应用开发;5、游戏开发;6、桌面应用开发。

以上就是如何设置python脚本运行参数,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI