淺談python腳本設(shè)置運行參數(shù)的方法
正在學(xué)習(xí)Django框架,在運行manage.py的時候需要給它設(shè)置要監(jiān)聽的端口,就是給這個腳本一個運行參數(shù)。教學(xué)視頻中,是在Eclipse中設(shè)置的運行參數(shù),網(wǎng)上Django大部分都是在命令行中運行manage.py時添加參數(shù),沒有涉及到如何在pycharm中設(shè)置運行參數(shù)。以下是兩種設(shè)置運行參數(shù)的方法(以manage.py為例),不設(shè)置運行參數(shù)時,運行結(jié)果為
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
沒有顯示監(jiān)聽端口,因為它本身缺少參數(shù)
1、常用的命令行設(shè)置參數(shù)的方法
D:\Django project\DjangoProject1>python manage.py runserver 0.0.0.0:8000
在manage.py腳本的根目錄下運行cmd,輸入python manage.py + 參數(shù),以下是運行結(jié)果
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
成功監(jiān)聽到了8000端口
2、在pycharm中設(shè)置運行參數(shù)
run --> Edit Configurations -->Scrip parameters


設(shè)置好之后運行
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.
成功監(jiān)聽8000端口。
以上這篇淺談python腳本設(shè)置運行參數(shù)的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
解決python-docx打包之后找不到default.docx的問題
今天小編就為大家分享一篇解決python-docx打包之后找不到default.docx的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-02-02
修復(fù)CentOS7升級Python到3.6版本后yum不能正確使用的解決方法
這篇文章主要介紹了修復(fù)CentOS7升級Python到3.6版本后yum不能使用的問題,本文給大家?guī)砹私鉀Q方法,需要的朋友可以參考下2018-01-01
Python使用Slider組件實現(xiàn)調(diào)整曲線參數(shù)功能示例
這篇文章主要介紹了Python使用Slider組件實現(xiàn)調(diào)整曲線參數(shù)功能,結(jié)合實例形式分析了Python使用matplotlib與Slider組件進(jìn)行圖形繪制相關(guān)操作技巧,需要的朋友可以參考下2019-09-09
Python如何設(shè)置utf-8為默認(rèn)編碼的問題
這篇文章主要介紹了Python如何設(shè)置utf-8為默認(rèn)編碼的問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-06-06

