上一页 1 ··· 24 25 26 27 28
摘要: 第八章、 第一个python程序#!/usr/bin/env pythonimport osimport sysimport time source = [r'G:\s1', r'G:\s2']target_dir = r'G:\d' + os.sep today = target_dir + time.strftime('%Y%m%d')now = time.strftime('%H%M%S') comment = raw_input('Enter a commnet -->')if len 阅读全文
posted @ 2011-10-13 11:24 方倍工作室 阅读(307) 评论(0) 推荐(0) 编辑
摘要: Python中有三种内建的数据结构——列表、元组和字典。 1) Lists列表 [,] 列表是序列的一种 shoplist = ['apple', 'carrot', 'banana']print shoplist #['apple', 'carrot', 'banana']shoplist.append('orange') #末尾加入一个print shoplist #['apple', 'carrot', 'banana',  阅读全文
posted @ 2011-10-13 11:23 方倍工作室 阅读(886) 评论(1) 推荐(2) 编辑
摘要: 第六章、 模块1) 模块sys模块字节编译的.pyc文件,优化编译后生成pyo文件2) from..import语句import sys print 'The command line arguments are:' for i in sys.argv: print i print '\n\nThe PYTHONPATH is', sys.path, '\n' 3) __name__只想在程序本身被使用的时候运行主块,而在它被别的模块输入的时候不运行主块from sys import * print 'The command line a 阅读全文
posted @ 2011-10-13 11:21 方倍工作室 阅读(406) 评论(0) 推荐(0) 编辑
摘要: 第五章、 函数 定义语句后面要加冒号 1) 定义函数 def sayHello(): print 'Hello World!'sayHello() 2) 变量作用域 LEGB原则 L本地作用域 E上层结构中def或lambda的作用域 G全局作用域 B内置作用域3) 工厂/闭合函数 def maker(N): def action(X): return X ** N return action f = maker(2)print f #<function action at 0x00E87730>print f(3) #9print f(4) #16g =... 阅读全文
posted @ 2011-10-13 11:19 方倍工作室 阅读(520) 评论(0) 推荐(0) 编辑
摘要: 第四章、 控制流 控制语句后面要加冒号: 1) if语句 if guess == number: print 'Congratulations, you guessed it.' # New block starts hereelif guess < number: print 'No, it is a little higher than that' # Another blockelse:print 'No, it is a little lower than that' if not False and True: #组合条件 pri 阅读全文
posted @ 2011-10-13 11:14 方倍工作室 阅读(336) 评论(0) 推荐(0) 编辑
摘要: 第三章、 运算符与表达式 1) 运算符 + 加 - 减 * 乘 ** 幂 / 除 // 取整除 % 取模 << 左移 >> 右移 & 按位与 | 按位或 ^ 按位异或 ~ 按位翻转 < 小于 > 大于 <= 小于等于 >= 大于等于 == 等于 != 不等于 not 布尔“非” and 布尔“与” or 布尔“或”运算符优先级 建议用括号来设置优先级2) 表达式 length = 5 breadth = 2 area = length * breadth 阅读全文
posted @ 2011-10-13 11:12 方倍工作室 阅读(331) 评论(0) 推荐(0) 编辑
摘要: 第二章、 类型常量5,1.23,9.25e-3,’This is a string’,”It’s a string!”1) 数整数:2长整数:浮点数:3.23,52.3E-4复数:-5+4j,2.3-4.6jac =-8.33 +1.2j print ac.real #-8.33 print ac.imag #1.2 print ac.conjugate() #(-8.33-1.2j) 二进制:0b1000八进制:0o307十六进制:0xFF2) 字符串单引号(')'Quote me on this'双引号(")"What's your na 阅读全文
posted @ 2011-10-13 10:29 方倍工作室 阅读(529) 评论(0) 推荐(0) 编辑
摘要: 第一章、 简介官方介绍:Python是一种简单易学,功能强大的编程语言,它有高效率的高层数据结构,简单而有效地实现面向对象编程。Python简洁的语法和对动态输入的支持,再加上解释性语言的本质,使得它在大多数平台上的许多领域都是一个理想的脚本语言,特别适用于快速的应用程序开发。安装:Python:http://www.python.org/download/PyScripter:http://code.google.com/p/pyscripter/UltraEdit的Python语法高亮:http://www.ultraedit.com/downloads/extras.htmlPython 阅读全文
posted @ 2011-10-13 10:22 方倍工作室 阅读(804) 评论(1) 推荐(1) 编辑
上一页 1 ··· 24 25 26 27 28