python笔记3--进阶资源
Python标准库是一个丰富的库,在大多数时候,你可以在这个库中找到你所需的东西。这被称为Python的“功能齐全”理念。我强烈建议你在开始开发大型Python程序之前浏览一下Python标准文档。Python.org——Python编程语言的官方主页。你可以在上面找到Python语言和解释器的最新版本。另外还有各种邮件列表活跃地讨论Python的各方面内容。comp.lang.python是讨论Python语言的世界性新闻组。你可以把你的疑惑和询问贴在这个新闻组上。可以使用Google群在线访问这个新闻组,或加入作为新闻组镜像的邮件列表。《Python实用大全》是一个极有价值的
python笔记2
三、python脚本示例---------------------------------------------------DEMO ONE:创建一个备份重要文件的程序:1.python 如何调用系统命令,并分析输出zip_command = "zip -qr '%s' %s" % (target, ' '.join(source))os.system(zip_command) 示例:import ossource_dir = ['/home/tk']target_dir= '/home/wangmin'if not os.path.exists(target_dir): os.mkdir(target_dir) print 'create dir succefully!'gzip_command = "zip -qr '%s' %s" % (target_dir, ' '.join(source_dir))if os.system(gzip_comman
python笔记1
一、帮助系统:help(command|module) eg. help(list)二、python基础python数据结构:列表 list=['itemA','itemB','itemC']元组 array=('itemA','itemB',list)字典 dict={'itemA':'valueA','itemB':'valueB','itemC':'valueC'}list的使用:---------------------------------------------------arraylist = ['panda','dog','cat','monkey','mouse']print "the array's length is",len(arraylist)print "n"print "the first item is ",arraylist[0]arraylist.append('snake')print "nafter add an item
declare in shell
declare peset选项 -r 只读 1 declare -r var1 (declare -r var1与readonly var1是完全一样的) 这和C语言中的const关键字一样, 都用来指定变量为只读. 如果你尝试修改一个只读变量的值, 那么会产生错误信息. -i 整型 1 declare -i number 2 # 脚本将会把变量"number"按照整型进行处理. 3 4 number=3 5 echo "Number = $number" # Number = 3 6 7 number=three 8 echo "Number = $number" # Number = 0 9 #
Shell
shell脚本调试技术shell脚本报错:"[: =: unary operator expected"shell 判断文件或路径是否存在 shell中调用shell的三种方式&并行shell shell文汇[@more@]
shell脚本报错:"[: =: unary operator expected"
shell脚本报错:"[: =: unary operator expected"if [ $RETURN == "OK" ]; then echo "OK"fi此种情况若RETURN为空,则判定为 [ = "OK"],[与"OK"匹配缺少'['。[@more@]
shell 判断文件或路径是否存在
#!/bin/sh filePath="/Users/wade/" fileName="/Users/wade/Desktop/test.pdf" #这里的-x 参数判断$myPath是否存在并且是否具有可执行权限 if [ ! -x "$filePath"]; then mkdir "$filePath" fi #这里的-d 参数判断$myPath是否存在 if [ ! -d "$filePath"]; then mkdir "$filePath" fi #这里的-f参数判断$myFile是否存在 if [ ! -f "$fileName" ]; then touch "$fileName" fi #其他参数还有-n,-n是判断一个变量
一个可用与数据库SQL封装的脚本语言--TCL
TCL 一种适用于数据库开发的脚本处理语言,一些公司会用来封装sql脚本,在没有DB2,Oracle这样存在存在存储过程机制的数据库(比如:greenplum)中实现类似存储过程的作用,封装业务逻辑,实现海量数据在数据仓库系统的数据均衡分布,以及实现并行计算减低CPU/IO开销等.TCL是一种类似于Java的解释性语言,但与java不同它是一种脚本语言,是轻量级的,因此兼具解释性语言的跨平台性,兼容性,也具有脚本语言的简单灵活性.[@more@]