zoukankan      html  css  js  c++  java
  • Python学习笔记-基础语法

    多行代码

    Python语句中一般以新行作为为语句的结束符。

    但是我们可以使用斜杠( )将一行的语句分为多行显示,如下所示:

    #多行代码
    item_one=1;
    item_two=2;
    item_three=3;
    
    total = item_one + 
            item_two + 
            item_three
    print (total)

    括号内不需要斜杠  [], {} 或 ()

    Python 引号

    word = 'word'
    sentence = "这是一个句子。"
    paragraph = """这是一个段落。
    包含了多个语句"""
    
    print (word)
    print (sentence)
    print (paragraph)

    Python注释

     1、python中单行注释采用 # 开头。

    #注释

    2、python 中多行注释使用三个单引号(''')或三个双引号(""")。

    '''
    这是多行注释,使用单引号。
    这是多行注释,使用单引号。
    这是多行注释,使用单引号。
    '''
    View Code

    3、等待用户输入

    item_one= raw_input("please input a number:")
    item_two=2;
    
    print item_one
    print item_one + '+2=' + str(int(item_one)+item_two)
    View Code

    Print 输出

    x="a"
    y="b"
    # 换行输出
    print (x)
    print (y)
    
    print ('---------')
    # 不换行输出
    print (x),
    print (y),
    
    # 不换行输出
    print (x,y)
    View Code
  • 相关阅读:
    windows上设置代理
    docker 代理
    windbg随笔
    win10自带ssh server使用
    centos7 最小安装后,编译配置redsocks
    cef chromium 编译
    C++中的单例模式
    delete NULL
    音视频通讯能力提供商
    云视频会议解决方案
  • 原文地址:https://www.cnblogs.com/Evan-fanfan/p/7832590.html
Copyright © 2011-2022 走看看