zoukankan      html  css  js  c++  java
  • 基础语法

    内容:
    一:标识符

        第一个字母必须是字母或者是下划线,标识符区分大小写字母
        标识符(包括函数和变量)的命名规则-------
        抛出问题-----------到底应该遵循什么样的规则?
        前方高能-----------驼峰命名法(myFirstName)--属性+类型+对象描述
            -----------PEP8    pycharm采用的标识符命名规则            https://blog.csdn.net/qq_42543215/article/details/80933283

    二:关键字(保留字符)

        不能用作任何的标识符!
        import keyword
        keyword.kwlist
        获取所有的保留标识符
        

    三:多行输入

        (1)多行输入使用换行符 \ 即可
            高能:总结各种语言下的多行输入方法!
        (2)多行字符串使用换行符或者双引号

    四:注释
        1:#
        2:双引号进行块代码的注释。
        3:函数和类的定义中使用文档字符串!(函数定义时详细)

    五:简单的输入和输出
        input()
        print()
        
    五:帮助命令的使用----重点
        help()的使用

    学习代码:

     1 # -----------------------------------------------------------------------------------------------------#
     2 # 保留字符
     3 # -----------------------------------------------------------------------------------------------------#
     4 import keyword
     5 print(keyword.kwlist)
     6 
     7 # -----------------------------------------------------------------------------------------------------#
     8 # 多行输入
     9 # -----------------------------------------------------------------------------------------------------#
    10 # 多行输入代码
    11 my_str1 = 'abcd' \
    12           'efgh'
    13 print(my_str1)
    14 
    15 # 多行字符串
    16 my_str12 = 'Hello\nworld'
    17 
    18 print(my_str12)
    19 
    20 my_str3 = """Hello
    21 world"""
    22 print(my_str3)
    23 
    24 # -----------------------------------------------------------------------------------------------------#
    25 # 注释
    26 # -----------------------------------------------------------------------------------------------------#
    27 # 单行注释
    28 # 多行注释
    29 """
    30 a = 10
    31 b = 30
    32 c = 200
    33 """
    34 
    35 faith = '''
    36 a = 10
    37 b = 30
    38 c = 200
    39 '''
    40 print(faith)
    41 print(type(faith))
    42 faith1 = '''a = 10\nb = 30\nc = 200'''
    43 print(faith1)
    44 
    45 # -----------------------------------------------------------------------------------------------------#
    46 # 简单的输入
    47 # -----------------------------------------------------------------------------------------------------#
    48 
    49 my_var = input('this is a number:')
    50 print(my_var)




  • 相关阅读:
    ubuntu 12.04 挂载windows分区
    linux ubuntu12.04 配置jdk
    java.lang.IllegalStateException: Cannot forward after response has been committe
    linux ubuntu 安装vim!
    linux ubuntu12.04 eclipse安装 svn
    linux下 android环境配置!
    ubuntu 12.04 配置telnet
    测试下来比较好用的jquery upload插件——uploadify
    google市场又能用了
    当php.ini里post_max_size配置段使用简写法导致php无法接收$_POST值的!
  • 原文地址:https://www.cnblogs.com/faithyiyo/p/9706250.html
Copyright © 2011-2022 走看看