python while 循环语句

简介:

本实例使用python的while语句来进行刷自己博客

注:本功能只为展示python的强悍功能,不为攻击任何人,让我们做良民网友


//引入所需要的python包

import webbrowser as web  as是把包明子改或者叫连接为as
import time
import os
import random

//使用random包里面的randint方法来随机生成一个2到4的数字

count = random.randint(2,4) 

//这里是做了一个while嵌套
a = 0
while a <count:
    a = a+1
    i = 0
    while i <= 19:

        //使用webbrowser包里面的ope_new_tab方法来打开相应的url地址

        web.open_new_tab('http://xinsir.blog.51cto.com/5038915/1537866')  
        i = i + 1

        //当打开第二个窗口前,停留1秒钟时间
        time.sleep(1)
    else:

        //如果已经刷满20次,那么等待1秒然后关闭浏览器
        time.sleep(1)
        os.system('taskkill /F /IM chrome.exe')










本文转自 xinsir999 51CTO博客,原文链接:http://blog.51cto.com/xinsir/1538485,如需转载请自行联系原作者
目录
相关文章
|
1月前
|
Python
python用户输入和while循环(四)
python用户输入和while循环(四)
26 1
|
1月前
|
安全 Python
python用户输入和while循环(二)
python用户输入和while循环(二)
17 0
|
1月前
|
Python
在Python中while循环
在Python中while循环
17 1
|
1月前
|
Python
python用户输入和while循环(一)
python用户输入和while循环(一)
16 0
|
1月前
|
Python
Python循环语句
Python循环语句
17 0
|
1月前
|
存储 索引 Python
python用户输入和while循环(五)
python用户输入和while循环(五)
17 0
|
1月前
|
Python
python用户输入和while循环(三)
python用户输入和while循环(三)
19 0
|
1月前
|
存储 算法 索引
python用户输入和while循环(六)
python用户输入和while循环(六)
18 0
|
1月前
|
存储 索引 Python
python用户输入和while循环(七)
python用户输入和while循环(七)
16 0