好吧,我终于开始工作了。
基本上,我把整个
try
/
except
/
else
A中的子句
while True:
循环,与
其他的
套房是
break
语句和的结尾
除了
套房是
continue
语句。结果是,如果用户输入的地址没有完全兼容的XML-RPC2服务器监听,那么它现在会连续循环。结果如下:
#!/usr/bin/python -i
# -*- coding: utf-8 -*-
import xmlrpclib, socket
from sys import exit
# Create an object to represent our server.
#server = xmlrpclib.Server(server_url) and print 'Xmlrpclib.Server object `__main__.server\' of URL `', server_url, "' created"
server_url = str(raw_input("Server: "))
server = xmlrpclib.ServerProxy(server_url)
while True:
try:
server.system.listMethods()
except xmlrpclib.ProtocolError, socket.error:
print 'Unable to connect to server. Please try again'
server_url = str(raw_input("Server: "))
server = xmlrpclib.ServerProxy(server_url)
continue
except EOFError:
exit(1)
else:
break
print 'Xmlrpclib.Server object `__main__.server\' of URL `', server_url, "' created"
# Python interpreter starts...
非常感谢你!
…我得再等一天才能接受这个…