我在試圖從 bitbucket 中拉下一個 repo 的 python lambda 中有這個小代碼:
import git
def git_clone(username,password):
new_dir = os.getcwd() "/temp/"
os.chdir(new_dir)
GIT_URL = "https://{0}:{1}@bitbucket.org/test-project/test.git".format(username,password)
git.Git(new_dir).clone(GIT_URL)
git 方法接受我的用戶名但不接受我的密碼。我的密碼包含字母、數字和特殊字符。我收到這個錯誤:
URL using bad/illegal format or missing URL
這可能是格式問題嗎?
uj5u.com熱心網友回復:
如果使用 bitbucket,請參閱檔案
git clone "https://x-token-auth:{token}@bitbucket.org/<user_name>/"
或者
url = r"https://x-token-auth:{token}@bitbucket.org/<user_name>/"
git克隆網址
這是您的問題的解決方案。我測驗了它并且它有效。
#!/usr/bin/env python
import os
def git_clone(password, username):
if password and username:
url_string = r"git clone https://{}:{}@bitbucket.org/{}/test.git".format(username, password, username)
os.system(url_string)
git_clone(username="<username>", password="<password>")
如果這解決了您的問題,請不要忘記接受并將其作為正確答案
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/361021.html
