日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

django ipython shell_通過django的shell_plus編寫ipython腳本

發(fā)布時(shí)間:2025/3/11 python 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 django ipython shell_通過django的shell_plus編寫ipython腳本 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

I'm writing a shell script which runs a command through ipython with the -c option like this:

我正在編寫一個(gè)shell腳本,它通過ipython運(yùn)行一個(gè)命令,使用-c選項(xiàng),如下所示:

ipython -c "from blah import myfunct; myfunct()"

but I want to invoke ipython through django's shell_plus command so I can take advantage of all the stuff shell_plus automatically loads for me:

但是我想通過django的shell_plus命令調(diào)用ipython,這樣我就可以利用shell_plus自動(dòng)為我加載的所有內(nèi)容:

$ ./manage.py shell_plus

I can't just add "-c ..." to the end of that because manage.py doesn't know what to do with it. Is there any way to pipe the -c option somehow?

我不能只在結(jié)尾加上“-c…”,因?yàn)楣芾怼y不知道該怎么處理它。有沒有什么辦法來實(shí)現(xiàn)-c選項(xiàng)呢?

1 個(gè)解決方案

#1

2

There are a couple of ways to do this.

有幾種方法可以做到這一點(diǎn)。

Modify manage.py and add the -c option and remove it from sys.argv after processing

修改管理。並添加-c選項(xiàng)並從sys中刪除。argv處理后

Modify manage.py and monkeypatch shell_plus so it supports -c by default

修改管理。py和monkeypatch shell_plus默認(rèn)支持-c

Put your code in some file and call 'PYTHONSTARTUP=your_file ./manage.py shell_plus'

將代碼放在某個(gè)文件中,並調(diào)用'PYTHONSTARTUP=your_file ./manage。py shell_plus”

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

總結(jié)

以上是生活随笔為你收集整理的django ipython shell_通過django的shell_plus編寫ipython腳本的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。