【发布时间】:2018-08-11 10:23:12
【问题描述】:
我在 Jupyter Notebook 的单元格中有以下代码:
!git push origin master
这将询问我的 Github 密码,但由于我找不到输入密码的方法,因此单元继续运行。出于某种原因,我想以这种方式推送代码。
我尝试关注similar questions,但在我的情况下似乎没有任何效果。以下是我尝试过的方法,但没有成功:
import getpass
import os
password = getpass.getpass()
command = "git -S push origin master " #can be any command but don't forget -S as it enables input from stdin
os.system('echo %s | %s' % (password, command))
这是上面的日志:
unknown option: -S
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
【问题讨论】:
标签: python linux shell ipython jupyter-notebook