简明Python教程中一处小错

一个小错啦,不过对我这样的新手来说,还是值得为戒的。

1.20中文版PDF第69页例10.1,注释部分无关重要,所以去掉了~~

   1:  #!/usr/bin/env python
   2:  # Filename: backup_ver2.py 
   3:   
   4:  import os
   5:  import time 
   6:   
   7:  source=['/home/swaroop/byte','/home/swaroop/bin']
   8:  target_dir='/mnt/e/backup/' 
   9:  target=target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip'
  10:  zip_command="zip -qr '%s' %s" %(target,' '.join(source))
  11:  if os.system(zip_command)==0:
  12:      print 'Successful backup to',target
  13:  else:
  14:      print 'Backup FAILED' 

第十行加下划线的那个'%s'就是出错的地方啦,一个小的标点错误~开始还没注意,调了好半天才注意到的,囧。。

看到'Successful backup'的结果,狠小激动了一下~有点成就感~~

Advertisements
此条目发表在Python分类目录。将固定链接加入收藏夹。

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s