Python
文章平均质量分 66
一条狗
这个作者很懒,什么都没留下…
展开
-
CodeCademy | Python | 4. Date and Time
调用日期、时间 #从datetime library中输出日期、时间信息from datetime import datetime now = datetime.now() print now#输出为2015-04-22 09:49:26.038463,下面分别输出年、月、日print now.year print now.month print now.day print now.hour pr原创 2015-04-22 18:05:23 · 374 阅读 · 0 评论 -
CodeCademy | Python | 3. Strings & console output
字符串string储存:字母,数字,符号,需要用英文双引号”__”;name = "luog11" age = "23" 代码‘__’ 中,后一个单引号 ‘ 意味着代码的结束,其后面的不会被执行,使用 \ 修正;'there's a bike'改正为: 'there\'s a bike' 字符串counting:index——字符串string中字母计数是中0开始,比如yes中三个字母的inde原创 2015-04-20 20:32:02 · 371 阅读 · 0 评论 -
CodeCademy | Python | 7. Function
函数包括三部分:def function_name(parameter) 函数代码块以def关键词开头,后接函数标识符名称和圆括号()。 任何传入参数和自变量必须放在圆括号中间,圆括号之间可以用于定义参数。 函数的第一行语句可以选择性地使用文档字符串—用于存放函数说明。 函数内容以冒号起始,并且缩进。 注: ①parameter可以没有、可以有多个; ②函数在结尾的时原创 2015-04-26 22:39:42 · 452 阅读 · 0 评论 -
CodeCademy | Python | 5. Conditionals & Control flow
代码示例 def clinic(): print "you've just entered the clinic!" print "Do you take the door on the left or on the right?" answer = raw.input(Type left or right and hit the enter).lower() if answer == "lef原创 2015-04-22 19:44:41 · 652 阅读 · 0 评论 -
CodeCademy | Python | 6. Pyglatin
pyg = 'ay' #为单词最后要加的后缀ay your_word = raw_input('Enter a word:') #提示输入一个单词 # XXX.isalpha()用于检查字符串是否全为字母,如果是、则其结果为True if len(your_word) > 0 and your_word.isalpha(): word = your_word.lower() firs原创 2015-04-25 20:04:08 · 634 阅读 · 0 评论 -
Python基础教程 | 第一章 第二章 知识点
Python基础教程(第2版)@(编程语言)[编程:python]Python基础教程第2版 第一章 基础知识 模块 字符串 第一章小节 第二章 列表和元组 概要 通用序列操作 列表Python的苦力 元组不可变序列 第二章小节第一章 基础知识 关于除法 1 // 2 → 0 1.0 // 2.0 → 0.0 1.0 // 2 → 0.0 1 / 2 →0.5 1.0 / 2.0 → 0.5 长整原创 2015-04-30 16:58:28 · 771 阅读 · 0 评论 -
Python基础教程 | 第三章 字符串
1. 基本字符串操作标准序列操作:索引、分片、乘法、 成员资格、长度、最大最小值>>> website = 'www.baidu.com' >>> website[5] #索引 'a' >>> website[10:2:-2] #分片 'cuib' >>> 2*website #乘法 'www.baidu.comw原创 2015-05-12 23:22:45 · 576 阅读 · 0 评论 -
Python基础教程 | 第四章 字典
第四章 字典1 略去2 创建和使用字典 字典,通过 名字 引用 值 的一种数据结构,这种数据结构成为 映射(mapping),其中key唯一,而 值 不一定; 值 没有特定顺序,但都存储在一个特定的 键(key)中,键可以是数字、字符串、元组; 键—值 序列对称为 项; 字典构成:a_dict = {key_1:value_1, key_2, value_2,……},可以通过key来引用value,原创 2015-05-17 22:13:15 · 586 阅读 · 0 评论