快速入门

1.程序输出 print
2.程序输入 raw_input()
3.注释 #
4.操作符 + - * / // % **(乘方操作符) ([]) 索引操作符 ([:]) 切片操作符
5.字符串 * 星号用于字符串重复
6.列表和元组
列表元素:用中括号[]包裹,元素的个数及元素的值可以改变。
元组元素:用小括号()包裹,不可以更改,可以看成只读的列表。

aList = [1, 2, 3, 4]
aList  [1, 2, 3, 4]
aList[0]

aTuple = ('robots', 77, 93, 'try')
aTuple  ('robots', 77, 93, 'try')
aTuple[:3]

7.字典
aDict = {'host': 'earth'}

  1. if
    if expression:
    if_suite

    if x < .0:
    print "x" must be aleast 0'

if expression:
    if_suite
else:
    else_suite

if expression1:
    if_suite
elif expression2:
    elif_suite
else:
    else_suite

9.while 循环
while expression:
while_suite

for eachNum in [0, 1, 2]:
    print eachNum

10.文件和内建函数
open() file()

11.函数
def function_name ([argument]) :
"optional documentation string"
function_suite

def addMe2Me(x):
    'appley + operation to argument'
    return (x + x)

12.类

class ClassName (base_class[es]) :
    "optional documentation string"
    static_member_declarations
    method_declarations

13.模块

import module_name

module.function()
module.variable
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 前言 人生苦多,快来 Kotlin ,快速学习Kotlin! 什么是Kotlin? Kotlin 是种静态类型编程...
    任半生嚣狂阅读 26,276评论 9 118
  • 这一部分着重于介绍Powershell的程序知识,让我们能够编写功能强大的Powershell脚本,执行比较复杂的...
    乐百川阅读 4,421评论 1 16
  • Groovy是一门基于JVM的动态语言,很多语法和Java类似。大部分Java代码也同时是合法的Groovy代码。...
    乐百川阅读 3,626评论 0 15
  • 在本教程中,将探讨使用Ruby开始编程所需的基本语法,以及如何在30分钟内快速入门学习并使用Ruby编程语言。 注...
    易百教程阅读 7,333评论 1 36
  • 简介/声明 为什么要写此文呢?稍微有点Web基础的同学应该都知道网页的表单大多都要做表单验证。而正则表达式正好可以...
    Airmole阅读 1,692评论 4 21