多语言展示
当前在线:1489今日阅读:27今日分享:41

python 简明教程

Python作为一款简单易用的编程语言,越来越受到大家的欢迎。借此介绍一下Python的简单使用。
工具/原料
1

Python

2

PyLab or other IDE

方法/步骤
1

先用一个简单的例子作为介绍入门:文件备份,windows环境下import osimport timeimport syssource=['C:\\Users\\jyjh\\Desktop\\Source\\2.txt']target_dir = 'C:\\Users\\jyjh\\Desktop\\Backup\\'target = target_dir+time.strftime('%Y%m%d%H%M%S')+'.rar'zip_command = ''C:\\Program Files\\WinRAR\\WinRAR.exe' a %s %s -r'%(target,' '.join(source))print zip_commandif os.system(zip_command)==0:    print 'backup successfully!!! '+targetelse:    print 'backup failed!!!'

2

运行结果如图:

推荐信息