素材牛VIP会员
python代码优化问题
 诸***1  分类:Python  人气:911  回帖:1  发布于6年前 收藏
#!/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)

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

 标签:python

讨论这个帖子(1)垃圾回帖将一律封号处理……

Lv2 入门
高***售 JAVA开发工程师 6年前#1

修改后

 文明上网,理性发言!   😉 阿里云幸运券,戳我领取