天天看點

python 基礎

#!/usr/bin/env python

for a in [1,2]:

 for b in ['a','b']:

    print a,b

import os

if os.path.isdir("/tmp"):

 print "/tmp is a direcotry"

else:

 print "/tmp is not a direcotry"

class server(object):

 def _init_(self,ip,hostname):

 self.ip=ip

 self.hostname=hostname

ipython

import subprocess

subprocess.call(["ls","-l"])

調用函數 xx()