过7游戏用python怎么写

过7游戏用python怎么写,第1张

代码为:

import re

def xiny(x, y):

    return bool(re.findall(x, y))

i = 1

while i <= 100:

    if i % 7 == 0 or xiny("7", str(i)) == True:

        print("过", end=",")

    else:

        print(i, end=",")

    i = i + 1

输出结果

1,2,3,4,5,6,过,8,9,10,11,12,13,过,15,16,过,18,19,20,过,22,23,24,25,26,过,过,29,30,31,32,33,34,过,36,过,38,39,40,41,过,43,44,45,46,过,48,过,50,51,52,53,54,55,过,过,58,59,60,61,62,过,64,65,66,过,68,69,过,过,过,过,过,过,过,过,过,过,80,81,82,83,过,85,86,过,88,89,90,过,92,93,94,95,96,过,过,99,100,

for i in range(100):

if i % 7 == 0 or i % 10 == 7 or i // 10 == 7:

continue

print(i)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12039536.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存