我有一些代码,当按下按钮时会创建一个消息框,当我在IDLE中运行我的程序但是如果我在IDLE之外运行程序时会出现错误" name' messagebox'没有定义"为什么这只发生在IDLE之外执行?
def Reset():
ResetMess = messagebox.askyesno("Confirm Reset", "Are you sure?")
答案 0 :(得分:3)
在IDLE之外,必须明确导入消息框
import SoftLayer.API
USERNAME = 'set me'
API_KEY = 'set me'
client = SoftLayer.create_client_from_env(username=USERNAME, api_key=API_KEY)
accountService = client['SoftLayer_Account']
brandService = client['SoftLayer_Brand']
# Getting the brands
brands = accountService.getOwnedBrands()
for brand in brands:
brandId = brand['id']
# Getting the owned Accounts
accounts = brandService.getAllOwnedAccounts(id=brandId)
for account in accounts:
print(account['companyName'])