python中的print命令

时间:2016-06-23 08:32:40

标签: python printing

我的问题是解释器中的这个错误

 File "C:\Users\Salam\Desktop\kasiskiAttack.py", line 36
    print "%-10s %3d" % (sub, found+l)
                    ^
SyntaxError: invalid syntax

这是我的代码。我在shell命令提示符

中使用
def findsubs(text, l, list_ocurrences):
    for i in range(len(text)-l):
        sub = text[i:i+l]
        found = text[i+l:].find(sub)
        if found != -1:
            f = found+i+l
            if i>0 and text[i-1:i+l] == text[f-1:f+l]:
                continue
            if i+l < len(text) and text[i:i+l+1] == text[f:f+l+1]:
                continue            
            print "%-10s %3d" % (sub, found+l)
            a = found+l
            list_ocurrences.append(a)    
    return list_ocurrences

1 个答案:

答案 0 :(得分:0)

试试print ("%-10s %3d" % (sub, found+l)) 如果你在py3