首页 > python代码优化问题

python代码优化问题

#!/usr/bin/python


import re
import subprocess
from random import choice

vpnlist = subprocess.check_output(["expressvpn list"],shell=True)


re2 = re.findall(r'\t([\w ]+ - [\w ]+ - [\w]+)\t',vpnlist)
re3 = re.findall(r'\t([\w ]+ - [\w ]+)\t',vpnlist)
re4 = re.findall(r'\t([A-Z][\w]+)\t',vpnlist)
re4.extend(['Philippines (via Singapore)','India (via UK)'])
del re4 [0:2]

RD = choice(re2+re4+re3)

subprocess.check_output(["expressvpn connect",RD],shell=True)
print subprocess.check_output(["curl ipinfo.io"],shell=True)
print subprocess.check_output(["curl cip.cc"],shell=True)

这是我第一次写代码,幸运步向码农的第一步,这个主要是对我的代理进行随机的选取地址进行全球随机地区翻墙。但因为第一次写乱七八糟的,我看着都不舒服,请大神们帮我看看怎么做这个优化,先谢谢各位了。


修改后

【热门文章】
【热门文章】