Python 使用pexpect自动提交并推送到github

Python 使用pexpect自动提交并推送到github,python,github,pexpect,Python,Github,Pexpect,我正在尝试将文件夹中的所有数据推送到Github。如果我将以下命令简单地放在LinuxShell中,一切都正常,但它现在可以在Python脚本上使用Pexpect。 在我看来,这是一项非常简单且经常使用的任务,但我还没有找到任何适合这项任务的方法。 这是我的密码: import subprocess import pexpect from pexpect import spawn import os os.chdir("/home/python/Desktop/") subprocess.run

我正在尝试将文件夹中的所有数据推送到
Github
。如果我将以下命令简单地放在LinuxShell中,一切都正常,但它现在可以在
Python
脚本上使用
Pexpect
。 在我看来,这是一项非常简单且经常使用的任务,但我还没有找到任何适合这项任务的方法。 这是我的密码:

import subprocess
import pexpect
from pexpect import spawn
import os
os.chdir("/home/python/Desktop/")
subprocess.run("git add .", shell=True)
subprocess.run( '''git commit -m "update"''', shell=True)
child = pexpect.spawn('git push origin master')
child.expect('Username.+')
child.sendline('***n@mail.net')
child.expect('Password.+')
child.sendline('sdfsdfsdfsdfs')
result = str(child.before)
print(result)

同样的问题,我需要等待
EOF

import-pexpect
child=pexpect.spawn('git-push-origin-master')
expect('Username.*')
child.sendline(“”)
expect('Password.*')
child.sendline(“”)
child.expect(peexpect.EOF)
child.close()

同样的问题,我需要等待
EOF

import-pexpect
child=pexpect.spawn('git-push-origin-master')
expect('Username.*')
child.sendline(“”)
expect('Password.*')
child.sendline(“”)
child.expect(peexpect.EOF)
child.close()

您可以在
.git/config
中添加用户,它不会要求用户。您似乎可以使用模块gitpython进行添加-您可以在
.git/config
中添加用户,它不会要求用户。您似乎可以使用模块gitpython进行添加-