Python_0

作者: ToM华托福票圈最低 | 来源:发表于2018-08-13 15:57 被阅读0次

    Some basic concepts about Python:

    1. Function: Sth. that helps u directly or indirectly achieve some target
    2. DataType: Distinguish elements for different uses
    3. Grammar: Standards for coding
    4. Structure: Logic for coding
    5. Packages: Sth. that provide useful fuxs for u to manipulate

    Before coding(Notice & some Grammar):

    1. Encoding for Chinese:
    #-*- coding:utf-8 -*-
    

    Other Choices: GB2312、GBK、GB18030

    2.Path

    Ex. for linux

    $ PATH=$PATH:/usr/local/python3/bin/python3  
    
    3.Keywords

    Python has some keywords that cannot be edited or changed
    Ex: False,True,None,and,or,class,if,def,...,etc.

    For search:

    import keyword
    keyword.kwlist
    
    4.Indent 缩进 & Multi-line code

    Indent:
    Python use indent (TAB) to display code blocks (no use for {})

    if True:
        print ("True")
    else:
        print ("False")
    

    Multi-line code:
    Use " \ " to connect

    total = item_one + \
            item_two + \
            item_three
    
    5. Print & Import

    Print in Python 3.0:

    a="x"
    print(a)   #output with "Enter" 换行
    print (a,end=" ")    #output with " " 不换行 
    

    Import:
    将整个模块(somemodule)导入
    从某个模块中导入某个函数
    从某个模块中导入多个函数
    将某个模块中的全部函数导入
    分别对应:

    import somemodule
    from somemodule import somefunction
    from somemodule import firstfunc, secondfunc, thirdfunc
    from somemodule import *
    

    相关文章

      网友评论

        本文标题:Python_0

        本文链接:https://www.haomeiwen.com/subject/ycsubftx.html