程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python Basics_ grammar

編輯:Python

# == == == == == == == == == == == == == == == ==
# Author:henry
# Time:2020/5/19 13:47
# Project:2020.05.18python grammar
# email:[email protected]
# == == == == == == == == == == == == == == == == =


# Python How to execute :
# 1.cmd Execution of terminal commands :python py Path to file
# 2.Pycharm In file , Right click the blank space to execute
# 3.Pycharm in , Click Run to execute

# pip command : Online installation of third-party packages , Manage third party packages
# 1. Installation package :pip install Library name
# 2. Uninstall package :pip uninstall Library name
# 3. Upgrade package :pip install -U Library name
# 4. List installed packages :pip list
# 5. View the current pip Version of :pip --version
# 6. Generate requirements.txt:pip freeze > requirements.txt
# 7. install requirements.txt:pip install -r requirements.txt

# python Basic syntax :
# Include indent , Line break , alignment , notes , Output
# 1. Line break : Each line does only one thing , Include \n Line break
# print(' Today is the first 30 First class of phase \n Write code \n Write the code ')  # \n Line break

# 2. notes : explain
# # Represents a single line comment     Shortcut key :ctrl + /
# Multiline comment   Three quotes ( Include single and double quotes )
'''print('hello,world!!')'''     # ctrl + B View the source code
"""print('hello,world!!')"""

# 3. Output :
# print('xxxxxx')   Output function

# 4. Variable
# What is a variable : Is used to identify data ,   grammar : Variable name = value ( data )

# Variable naming conventions :
# 1. By digital , Letters and underscores make up
# 2. Cannot start with a number
# 3. It can't be a keyword
import keyword             # View keywords
print(keyword.kwlist)     # Print
# 4. Case sensitive

# Variable ( identifier )= value / data ( data type )
'''today = 'hello,wprld!!'     # assignment
print(today)'''    # Print

# Variable ( identifier ) The naming style of :
# 1. Underline nomenclature ( Mainly python):hello_world
# 2. The name of the great hump :HelloWorld
# 3. Little hump nomenclature :hellWorld

# python data type
# 1. String type (str): Include values enclosed in single and double quotation marks
# 2. The number : Integers (int) There is no decimal point 、 Floating point numbers (float) There's a decimal point
# 3. Boolean value (bool):True( really )、False( false )
'''is_ten = False
after_ten = True'''

# 4. Get the current data type :type( data )
'''age = 18
number = 10.5
study = ' Study '
print(type(age))    # Integer types
print(type(number))  # Floating point type
print(type(study))'''    # String type


# Homework after class
'''
One 、 The following cannot be used as variables ?
1、find     2、 _num    3、7val        4、add.       5、def     
6、pan      7、-print   8、open_file   9、FileName   10、9prints  
11、INPUT   12、ls      13、user^name  14、list1     15、str_
16、_888    17、is      18、true       19、none      20、try  

The following cannot be used as variables
3、7val( Cannot start with a number )、4、add.( No symbols )、5、def ( No keywords )、 7、-print( Can not be )
10、9prints、( Cannot start with a number )、13、user^name( No special symbols )17、is( No keywords )、20、try( No keywords )

Two 、 Please describe the naming conventions of variables ,( Simple questions )

Variable naming conventions :
1. Cannot start with a number
2. By digital , Letters and underscores make up
3. Cannot use keyword
4. Be case sensitive
'''
'''
3、 ... and 、python How to add comments

There are two notes :
1. A single line comment can be made with :# notes     Shortcut keys are ctrl + /
# Single line notes explain
2. Multiline comment : Three quotes ( Include single and double quotes )'''
''' This is how you annotate multiple lines ,      # Three quotation marks ( Single quotation marks )
Don't use single line comments line by line '''
''' This is how you annotate multiple lines ,      # Three quotation marks ( Double quotes )
Don't use single line comments line by line '''
 

 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved