刚接触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. https证书安装无效的主要原因

    https证书的作用是为了确认服务端身份,但网络上充满了无效的证书,浏览器对使用无效证书的访问,给出危险.不安全警告,将是否选择继续访问由用户选择,而大多数用户是无法区分这是配置还是真的存在安全问题. ...

  2. UVA489 - Hangman Judge【紫书例题4.2】

    题意:就是给出一个字符串,让你去一个一个猜测,相同字母算一次,如果是之前猜过的也算错,如果你在错7次前猜对就算你赢,文章中是LRJ的例题代码. #include<stdio.h> #inc ...

  3. Ubuntu Server下docker实战 01: 安装docker

    本系列文章主旨在于使用docker来搭建实际可用的基础服务,具体到每一步的操作和设置. 关于docker的原理.前世今生的内容,园子里已经有太多的文章了,此处就不再赘述. 要使用docker,当然第一 ...

  4. 在微信小程序里使用 watch 和 computed

    在开发 vue 的时候,我们可以使用 watch 和 computed 很方便的检测数据的变化,从而做出相应的改变,但是在小程序里,只能在数据改变时手动触发 this.setData(),那么如何给小 ...

  5. spi简介(自我理解)

    因为项目中用到spi总线,网上看了下资料,总感觉云山雾罩的,就向身边的同事问了下,他给我解释了下, 我现在把自己理解的写下来 spi一共四条线,一条选择线,一条数据线,2条数据线.spi是一对多设备, ...

  6. PAT 1079. Total Sales of Supply Chain

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  7. 洛谷—— P1097 统计数字

    https://www.luogu.org/problem/show?pid=1097 题目描述 某次科研调查时得到了n个自然数,每个数均不超过1500000000(1.5*10^9).已知不相同的数 ...

  8. Spring Boot实例Hello World Demo

    Spring Boot要求Maven的版本达到3.2或以上. 实例: POM: <project xmlns="http://maven.apache.org/POM/4.0.0&qu ...

  9. [jQuery]$.get跨域提交不发送原因

    使用 $.ajax({ url: "http://pastebin.com/embed_js.php?i=sy9gt3FR", dataType: "jsonp" ...

  10. HDU 2912

    直线关于球的多次反射,求最后一次反射点 #include <iostream> #include <cstdio> #include <cstring> #incl ...