请耐心等待我,我还是新手编程,所以我试图读取文件并将一些文本存储到变量中,这是我的代码:
fo=open(vpn_account)
for line in fo:
if line.find('remote')==0:
vpn=line.split()
if len(vpn) > 1:
servervpn=vpn[1] + ":" + vpn[2]
hostvpn=vpn[1]
portvpn=vpn[2]
print servervpn
fo.close()
当它读取下面的文件时会返回49.213.16.5:443
,这就是我想要的。
dev tun
proto tcp
remote 49.213.16.5 443
http-proxy-retry
http-proxy 49.213.16.5 8080
keepalive 4 30
cipher AES-128-CBC
auth SHA1
resolv-retry infinite
nobind
persist-key
persist-tun
client
verb 3
auth-user-pass user.txt
route 0.0.0.0 0.0.0.0 vpn_gateway
route 0.0.0.0 0.0.0.0 net_gateway
route-method exe
route-delay 2
pull
mute-replay-warnings
tun-mtu 1500
mssfix 1430
redirect-gateway def1
dhcp-option DNS 8.8.8.8
dhcp-option DNS 8.8.4.4
<ca>
-----BEGIN CERTIFICATE-----
MIIDzjCCAragAwIBAgIBADANBgkqhkiG9w0BAQsFADBmMRYwFAYDVQQDDA1ERUxU
QSBTU0ggVlBOMRcwFQYDVQQKDA5ERUxUQSBDT01QVVRFUjELMAkGA1UEBhMCSUQx
EjAQBgNVBAgMCUluZG9uZXNpYTESMBAGA1UEBwwJRWFzdCBKYXZhMB4XDTE1MDEw
NjA4NDg1OFoXDTI1MDEwMzA4NDg1OFowZjEWMBQGA1UEAwwNREVMVEEgU1NIIFZQ
TjEXMBUGA1UECgwOREVMVEEgQ09NUFVURVIxCzAJBgNVBAYTAklEMRIwEAYDVQQI
DAlJbmRvbmVzaWExEjAQBgNVBAcMCUVhc3QgSmF2YTCCASIwDQYJKoZIhvcNAQEB
BQADggEPADCCAQoCggEBANoYM2+r1IaiDoBmZbylWpfKz/XEFmiEH0oLBl7EzFB6
rtaz9XjbkU6TyFQcnL3AWHKbkP7Gs7oJKwAexb5mQ3jVEIU+krQ4yl89wE86DleU
Kd1ez76XjbYzMMRFukJC/EiGJXfQAvctgFIRUKbruppbFMjbSGFovfPzll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mOVHd1G4NlAEI/GfahRlUi+fRWF69+LmUCgYAXskmqZ25kh3Y+Xp4A0hBY
2Jd46KUzlaJppTSmf5DdjpkyAA21nXdGDkedmEU4HexWYAEpgxAwE9olxwn+EsKm
k5B8lfiKrV9EaCplR+mP94jQGlN1iw45+fUtfQ+P+hnmJWMRlBmtu36rLP1zNkxA
iFrjJOigjMVHkFnDC16/HQKBgGE2hHjB5UvdZKPW03Ia/8pdaCSP81dJMuchPi3B
hI2oiy5e4XmFFFMwaj4jPxO1ufuAmfBuY1nUg7pMOUwkI1zAgLK8M4J+3c01IOhM
uzRiZ1+lYQ6/7dTHprer3tmpOnLhNR3sDdHVnlvP1GkcOhchGq2TIOYJeOrSTyfg
Dz6xAoGAZBVGUpSVDAe71LkGigb5SqK+0MpfbESL6jwWwGy1+TDVRPGJthxFWIaA
EIJjdEnWIW8b3gENQavRY2E/gurZVjJ0BuYF4wbzeGd+CKTFAJb5POSOzRKMT127
konRU5LiDTsm7iLQjqacXe7GAisGAVQ7dz1LeTuUHHrdWhMJikk=
-----END RSA PRIVATE KEY-----
</key>
但是当脚本读取下面的文件时,我得到:
Traceback (most recent call last):
File "./test", line 12, in <module>
print servervpn
NameError: name 'servervpn' is not defined
这里是脚本有问题的文件:
client
dev tun
proto tcp
remtote 45.64.99.44 443
resolv-retry infinite
nobind
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
persist-key
persist-tun
auth-user-pass id2tcpvpncom443.txt
comp-lzo
reneg-sec 0
verb 3
<ca>
-----BEGIN CERTIFICATE-----
MIIE4jCCA8qgAwIBAgIJANc096jxw0XjMA0GCSqGSIb3DQEBCwUAMIGmMQswCQYD
VQQGEwJpZDELMAkGA1UECBMCaWQxEzARBgNVBAcTCnRjcHZwbi5jb20xEzARBgNV
BAoTCnRjcHZwbi5jb20xEzARBgNVBAsTCnRjcHZwbi5jb20xEzARBgNVBAMTCnRj
cHZwbi5jb20xEzARBgNVBCkTCnRjcHZwbi5jb20xITAfBgkqhkiG9w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rRzCDRpXxEaAhZjvwa5AI7z/n
OqchxxVOn4RsA1DoiSBvqyLwYhylQPZk/61knEET4eCF8p+BdDXTPCTM3PV2PLhx
qaptqonLVxfnuEN2CwU4MB5psLRVcPZWeBMo5BR/rA47fLjITy+1QI9HQ5QQzfK/
/QrSHIp5x1sCgYEAtCCd4XIQuceIyzBSAkkstjV3LnJS1427YzpptOclt5Dvoz5D
xaPi/RweHTHUOLlkjSqAriVVkVv5Hd06RErISQeqcJotVSwMia8v3D3S3w1zd4PF
LPrShsHIfjII07eZqdesLIO0DzSiuX6cAIlQQUqsP/CJzRVrZFC2ypUdxAkCgYEA
vn87sMbmyQDRtbu797cbY1fb8yiQ89g4g7JzfJDM78PbD7O3xSma5mqaVfeotcIG
UInZTdjVPqYC0/RCL28U2cNC4ZT9FBUAc1iEIVR8zeHuGkMiNYN6z3e/nFPzsr5c
V4M4n3S7ETy/ayF22WCZL5Vha0PjKVH6zOBpIV2cr9UCgYAnA2o8tM6QNZxg3i8R
IC/cVmI7qzcMAlIZxXu8g4SUJGrXeqSR1sN273Nx6uIw83Oj2Cnk+qQn/ElRcpg5
eZui4JAaWSS+AD0acmq2h94Yvd6QinJ1bm5VJi35MHANG7D0/VVxG7icTuRnZevQ
k+iIuH6zfsYWjL2hoSkG1OTvJA==
-----END PRIVATE KEY-----
</key>
我真的不知道脚本有什么问题,我该如何解决?
答案 0 :(得分:0)
您的文件中有remtote
而不是remote
:没有符合匹配项(if line.find('remote')==0:
永远不会True
):servervpn
永远不会被定义,因为你甚至没有进入if
条件
您必须使代码对错误更加健壮
with open(vpn_account) as fo:
for line in fo:
if line.find('remote')==0:
vpn=line.split()
if len(vpn) > 2:
servervpn=vpn[1] + ":" + vpn[2]
hostvpn=vpn[1]
portvpn=vpn[2]
break # no need to continue reading the file: we found the pattern
else:
raise Exception("no remote line found")
else
条件与for
循环相关。如果没有break
,则执行else
代码,并引发显式异常。
答案 1 :(得分:0)
根据您的代码逻辑,您逐行读取文本文件并搜索以remote
开头的行,如果找到,那么您正在初始化一个局部变量servervpn
,该变量将在for
循环
请注意servervpn
是在if
条件内创建的局部变量,因此如果不满足if
条件(如第二个文本文件中那样没有行开头)使用remote
),然后变量不会被创建,从而导致错误。