空行上的语法无效

时间:2014-07-18 16:26:45

标签: python

出于某种原因,我收到了错误:

File "prode.py", line 50

                                                                                                        ^
SyntaxError: invalid syntax

这就是我的代码:

def start():
#Is the user trying to get pixel or percentage data,
if (len(sys.argv)) == 4:
    if (sys.argv[1]) == "-px":
        pct = float(sys.argv[2])
        pxl = float(sys.argv[3])
        divByCent = pct*pxl
        ans = divByCent/100
        print "%f pct of %f px = %f px" % (pct, pxl, ans)
    elif (sys.argv[1]) == "-pe":
        pxlOne = float(sys.argv[2])
        pxlTwo = float(sys.argv[3])
        divByTwo = pxlOne * 100
        ans = divByTwo / 1280
        print "%f pxl of %f pxl = %f pct" % (pxlOne, pxlTwo, ans)
#Or something based on a ratio?
elif (len(sys.argv) == 3):
    if (sys.argv[1] == "-use"): ratioCalc = Ratio(float(sys.argv[2]), float(sys.argv[3])

    #Line 50

有人知道这是从哪里来的吗?

1 个答案:

答案 0 :(得分:10)

你错过了最后一个括号:

if (sys.argv[1] == "-use"): ratioCalc = Ratio(float(sys.argv[2]), float(sys.argv[3]))