这个Python单行是什么意思?

hhh*_*hhh 6 python syntax

s=p=1;exec"if s%p*s%~-~p:print`p`+','+`p+2`\ns*=p*p;p+=2\n"*999
Run Code Online (Sandbox Code Playgroud)

资源.

kev*_*pie 11

这是对基本思想的解读.

# p = 1; s = p
s=p=1
#exec"if s%p*s%~-~p:print`p`+','+`p+2`\ns*=p*p;p+=2\n"*999
for i in range(999):
    # s%p = remainder of s/p
    # ~p = 1s complement of p
    if s%p*s%~-~p:
        # `p` = repr(p)
        print`p`+','+`p+2`
    # s = s*p*p
    s*=p*p
    # p = p+2
    p+=2
Run Code Online (Sandbox Code Playgroud)


esm*_*mit 7

它计算并打印孪生素数集.

3,5
5,7
11,13
17,19
29,31
41,43
59,61
71,73
101,103
107,109
137,139
.....
Run Code Online (Sandbox Code Playgroud)

很酷 :)