Python语法三

1. from os.path import exists

 import 了又一个很好用的命令 exists。这个命令将文件名字符串作为参 数,如果文件存在的话,它将返回 True,否则将返回 False

print "Does the output file exist? %r" % exists(to_file) 

2. 使用 def 新建函数

def print_two(*args):

   arg1, arg2 = args

   print "arg1: %r, arg2: %r" % (arg1, arg2) 

使用冒号结束函数定义,然后用四个空格的缩进行都属于函数内容

使用时直接:print_two("Zed","Shaw")

3. 

原文地址:https://www.cnblogs.com/agile2011/p/5525690.html