正在学习Django框架,在运行manage.py的时候需要给它设置要监听的端口,就是给这个脚本一个运行参数。教学视频中,是在Eclipse中设置的运行参数,网上Django大部分都是在命令行中运行manage.py时添加参数,没有涉及到如何在pycharm中设置运行参数。以下是两种设置运行参数的方法(以manage.py为例),不设置运行参数时,运行结果为

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脚本设置运行参数的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。