不乱于心,不困于情。
不畏将来,不念过往。如此,安好。

使用Python进行ADSL宽带拨号连接

1、导入相关包

import time, os
from datetime import datetime

2、函数版

# 连接ADSL
def connect_ADSL(name,username,password):
    cmd_string = f'rasdial {name} {username} {password}'
    os.system(cmd_string)
    time.sleep(5)

# 断开ADSL
def disconnect_ADSL(name):
    cmd_string = f'rasdial {name} /disconnect'
    os.system(cmd_string)
    time.sleep(5)

# 重连ADSL
def reconnect_ADSL(name,username,password):
    disconnect_ADSL(name)
    connect_ADSL(name, username, password)

3、ADSL类

class ADSL(object):
    def __init__(self):
        self.name = ''
        self.username = ''
        self.password = ''

    def set_adsl(self, account):
        self.name = account["name"]
        self.username = account["username"]
        self.password = account["password"]

    def connect(self):
        cmd_str = f"rasdial {self.name} {self.username} {self.password}"
        os.system(cmd_str)
        time.sleep(5)

    def disconnect(self):
        cmd_str = f"rasdial {self.name} /disconnect"
        os.system(cmd_str)
        time.sleep(5)

    def reconnect(self):
        self.disconnect()
        self.connect()
赞(0) 打赏
未经允许不得转载:seo优化_前端开发_渗透技术 » 使用Python进行ADSL宽带拨号连接

相关推荐

  • 暂无文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏