Windows Python 2.7 需设置CATALINA_HOME环境变量 
import  os
import  time
import  subprocesstomcatStartFilePath =  'C:\\tomcat\\apache-tomcat-7.0.90-windows-x64\\apache-tomcat-7.0.90\\bin\\startup.bat' 
browserPath =  'C:\\Users\\Administrator.USER-20180302VA\\AppData\\Local\\360Chrome\\Chrome\\Application\\360chrome.exe' 
appAddress =  "http://localhost:8080/nice" 
subprocess. Popen( tomcatStartFilePath,  shell= True ) 
print  'Starting tomcat...' 
time. sleep( 15 ) 
print  'Polling...' 
startBrowerFalg =  False 
interval =  5 
count =  6 while  count >  0 : tmpFile =  os. popen( 'netstat -na' , 'r' ) breakWhileFlag =  False for  line in  tmpFile. readlines( ) : if  line. startswith( '  TCP    0.0.0.0:8080' ) : breakWhileFlag =  True break print  "Not yet." if  breakWhileFlag: print  "It's Ok." startBrowerFalg =  True break else : count -=  1 time. sleep( interval) 
if  startBrowerFalg: print  "Launch the browser." subprocess. Popen( '%s %s' % ( browserPath,  appAddress) ) 
else : print  "Something wrong ..." raw_input ( ) 
如何通过批处理调用tomcat的startup.bat,然后在tomcat启动成功后,自动打开浏览器并定位到指定网址 Python编程快速上手