gpt4 book ai didi

python - 为什么意外缩进?

转载 作者:太空宇宙 更新时间:2023-11-04 06:49:31 27 4
gpt4 key购买 nike

为什么会这样?

def LoadPackageList():
try:
#Attempts to load package list... Adds each neccessary attribute into array
print("Loading Package List... please wait")
packages = []
packagelisturl = os.getcwd() + "packages.list"
dom = minidom.parse(urllib.urlopen(packagelisturl))
try:
for eachattributeofpkglist in dom.GetElementsByTagNameNS(packagelist, 'packages'):
packages.append({
'title': node.getAttribute('title'),
'shortname': node.getAttribute('shortname'),
'dlurl': node.getAttributes('dlurl'),
'description': node.getAttributes('description'),
'tags': node.getAttributes('tags'),
'infopage': node.getAttributes('infopage'),
'quality': node.getAttributes('quality'),
'id': node.getAttributes('id')
})

except LoadPackageListFailed:
print("Loading Package List failed... try again soon or manually update this release!")
Write2ErrorLog(LoadPackageListFailed)
#Indent Here Fails
def Usage():
#prints usage and closes
print ("Invalid Argument Specified, please retry using the format stated below\n")
print ("*** Simtho Usage Parameters ***\n")
print ("-i Installs Local App, include full path")
print ("-u Uninstalls Installed App,include ID or Name")
print ("-l Lists all installed Apps and their ID")
print ("-a Lists All Apps in Repository")
print ("-s Downloads and Installs App from repository, enter the title or id number")
print ("-w Downloads and Installs Single App from a full link")
print ("-r Removes All Packages installed\n")
print ("*** End of Simtho Usage ***")
os._exit(1)
return;

最佳答案

尝试通过 python -t 运行它,看看其中某处是否混合了制表符和空格。

作为旁注:使用 optparse处理命令行参数。它将使您的生活更轻松,并产生一个漂亮的一致界面。

关于python - 为什么意外缩进?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1983405/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com