码迷,mamicode.com
首页 > 编程语言 > 详细

Python语法三

时间:2016-05-25 08:13:58      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:

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. 

 

Python语法三

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!