-2
我沒有python的經驗。我正試圖弄清楚如何從命令行觸發這部分代碼。我發現的問題是,它看起來像「UserAccount()」是一個對象,我不知道如何從命令行觸發。所以a)什麼是UserAccount? b)我如何從命令行調用這個參數?從命令行調用python類
# Create a random use account
randomInt = random.randint(1, 4294967295)
accountId = "random_id+" + str(randomInt) + "@acme.com"
randomInt = random.randint(1, 4294967295)
password = "Random_password1_" + str(randomInt)
primaryEmail = accountId
userAccount = UserAccount()
userAccount.accountId = accountId
userAccount.password = password
userAccount.primaryEmail = primaryEmail
userAccount.firstName = "Random"
userAccount.lastName = "User"
userAccount.birthdayMonth = 5
userAccount.birthdayDay = 31
#userAccount.firstNamePhonetic = ""
#userAccount.firstNameRomagi = ""
#userAccount.middleName = ""
#userAccount.middleNamePhonetic = ""
#userAccount.middleNameRomagi = ""
#userAccount.lastName = ""
#userAccount.lastNamePhonetic = ""
#userAccount.lastNameRomagi = ""
#userAccount.companyName = ""
#userAccount.securityQuestion = ""
#userAccount.securityAnswer = ""
#userAccount.locale = ""
#userAccount.timeZone = ""
#userAccount.allowUpdateNotification = False
#userAccount.allowThirdPartyNotification = False
# Assume for now that we're just creating a user account, not also requesting activate/deactivate
# permissions by providing a pre-created OAuth client ID.
oauthClientId = "";
print(" Test creating an account: " + userAccount.accountId + ", password: " + userAccount.password + ", email: " + userAccount.primaryEmail)
accessToken = client.createAccount(userAccount, oauthClientId)
print(" Account created!")
if accessToken:
print(" Access token for account: " + accessToken)
print()
看看'argparse' – OMGtechy
https://docs.python.org/3/library/__main__.html – aSteve