刚接触python,mark下所见所得:

1.Python调用底层API,可在任何platform上运行,包括Windows、Mac、Unix;

2.用#符号对代码或语句进行注释,#后的代码不被编译;

3.print的时候使用逗号[,]告诉解释器不作新行输出;

4.python程序可以运行在windows shell里(cmd line);

5.代码可以在notepad下编辑,纯文本结构文件;

6.变量声明:v=2; v="can be changed to a string"; #the value of v can be changed at any time;

      name="paul cheng";同样用加号进行字符串连接;

7.while循环:[代码逻辑结构完全用缩进控制,新鲜清洁]

    n=1

    while n<10:

      print n

      n=n+1

8.function:

  1)definition:

    def hello():

      print "hello"

      return 1234

  2)invoke:

    "print hello()" will output result like: [after execution of print "hello", function returns 1234 for printing]

      hello

      1234

9.Tuples, Lists, Dictionaries.

    1)Tuples: month = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun')

    2)Lists: cats = ['Tom', 'Snappy', 'Kitty', 'Jessie', 'Chester']

        add: cats.append("appendOne")

        delete: cats.remove("Tom") or del cats[n];

        get one: cats[1] will get "Snappy";

        get many: cats[0:2] will get "'Tom','Snappy','Kitty'";

    3)Dictinonaries: phonebook = {'paul cheung':123456, 'chirs paul':654321}

        add: phonebook['key']=value

        delete: del phonebook['key']

        keys: phonebook.keys() will return all keys as a list;

        values: phonebook.values() will return all values as a list;

10.loop-for:

    for item in list:

      print item

11.class:

    class person:  #definition

      def _init_(selef, name, age):  #.ctor

        self.name=name

        self.age=age

    class student(person):  #inheritence

      {statement...}

12.module: #include variables/function/class;

13.import module:

    import module_name

    from module_name import function_name/class_name

14.use imported module:

    module_name.function_name/class;

    function_name if use from...import...

15.file I/O:

    file = open('file_name', 'r/w')

    file.seek(int, int) #moving cursor

16.error handling:

    try:

      {statement...}

    except NameError:

      {...}  #handle a type of error

    except SyntaxError:

      {...}  #handle another type of error

    or except (NameError, SyntaxError)

      {...}  #handle multilple types of error together

管窥python语法的更多相关文章

  1. 对 Python 语法不够了解导致的 bug

    对 Python 语法不够了解导致的 bug. `in` '20' in '11264,6144,4096,3072,2048,1024,300,30' Out[7]: True a_list = ' ...

  2. python 笔记2:python语法基础

    python语法学习笔记: 1 输入输出 input(),print(). name = input('input your name : ')print('hello ,'+name)print(& ...

  3. python语法快速入门(1)

    http://www.runoob.com/python/python-tutorial.html Python 是一种解释型语言: 这意味着开发过程中没有了编译这个环节.类似于PHP和Perl语言 ...

  4. python语法笔记(四)

    1.对象的属性     python一切皆对象,每个对象都可能有多个属性.python的属性有一套统一的管理方案. 属性的__dict__系统     对象的属性可能来自于其类定义,叫做类属性:还可能 ...

  5. python语法-[with来自动释放对象]

    python语法-[with来自动释放对象] http://www.cnblogs.com/itech/archive/2011/01/13/1934779.html 一 with python中的w ...

  6. wxpython 支持python语法高亮的自定义文本框控件的代码

    在研发闲暇时间,把开发过程中比较重要的一些代码做个珍藏,下面的代码内容是关于wxpython 支持python语法高亮的自定义文本框控件的代码,应该是对大家也有用. import keywordimp ...

  7. Python语法的转义字符

    Python语法的转义字符 转义字符 说 明 \ 续行符 \n 换行符 \0 空  \t 水平制表符,用于横向跳到下一制表位 \'' 双引号 \' 单引号 \\ 一个反斜杠 \f 换页 \0dd 八进 ...

  8. Python语法教程总结规范

    Python语法易错点记录 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分享. ...

  9. 初试Python语法小试牛刀之冒泡排序

    Python很火,心里很慌,没吃过猪肉,也要见见猪走路. 看了几天Python的语法,大概初步了解了一点点,https://www.liaoxuefeng.com/wiki/0014316089557 ...

随机推荐

  1. XX-Net的完整教程

    1.下载谷歌浏览器,安装. 2.百度搜索github,github中搜索XX-Net,下载稳定版 3.解压缩下载的文件夹,运行start.vbs文件.如果弹出管理员请求权限请允许,弹出防火墙警告,请允 ...

  2. 在阿里云的ubuntu服务器上安装xampp时出现unable to realloc unable to realloc 8380000 bytes错误

    在阿里云的ubuntu服务器上安装xampp时出现unable to realloc unable to realloc 8380000 bytes错误 解决:增加Swap空间(阿里云缺省没有分配任何 ...

  3. Google Shell Style Guide

    转自:http://google.github.io/styleguide/shell.xml Shell Style Guide Revision 1.26 Paul Armstrong Too m ...

  4. nyoj112-指数运算

    指数运算时间限制:600 ms  |  内存限制:65535 KB难度:2描述写一个程序实现指数运算 X^N.(1<X<10,0<N<20)输入输入包含多行数据 每行数据是两个 ...

  5. 【密码学】RSA加密 kotlin实现方法(支持任意字节长度)

    这个编辑器不支持kotlin,尴尬了···· 算了,就用Java来弄吧 val 定义常量 var 定义变量 具体kotlin的开发手册详见:http://www.runoob.com/kotlin/k ...

  6. 08.Web服务器-5.深入理解HTTP协议(大图)

  7. 自学python 第三天

    #!/usr/bin/env python# -*- coding:utf-8 -*- # name = "***"# if "*" in name:# pri ...

  8. 暑假集训D14总结

    %dalao 今天dalao继续来讲课~讲的是一个叫kd树的奇怪东西= = 然而啥都没听懂 考试 今天多校联考,日常炸= = 照例打了前两道题的暴力(T1随便hash一下就水过了啊喂),然后开始推T3 ...

  9. isap算法模板poj 1273gap+弧优化 最大流

    几个比较好的博客 http://www.renfei.org/blog/isap.html http://kenby.iteye.com/blog/945454 http://blog.csdn.ne ...

  10. Wireshark中的一些SNMP相关的过滤器

    Wireshark中的一些SNMP相关的过滤器 转自 http://linmingren2003.blog.163.com/blog/static/567510032011419825097/   由 ...