`
(1).Python The grammar of a language is simple and flexible . Comparison C Language ,c++ and java Equal compiled language ,Python It seems simple .
(2). Normalized code
(3).Python It's an open source project , Free to developers .
(4).Python Is a programming language for object-oriented programming .
(5). Portability makes program development easier .
(6).Python It's an interpretative language
(7). Strong scalability
(8). It has a rich development support library
(9). Good concurrency support
however Python There are also many shortcomings , For example, the running speed is slow , Incompatible development versions, etc . I am based on Python 3.x Development . If a friend is using 2.x edition , You can change .
Python There are a lot of compilers for , One of them visual studio code,psycharm And other compilers are very good compiler software , Here I introduce vs code.
VSCode( Full name :Visual Studio Code) Is a cross platform free source code editor developed by Microsoft ,VSCode The development environment is very simple and easy to use .
VSCode It's easy to install , Open the website https://code.visualstudio.com/, Download the package , Step by step installation , Pay attention to the installation path setting during installation 、 Environment variables are automatically added to the system by default , Check all of the following options :
Create a Python Code file
open VScode, Click New... And then click :
Click to select language :
Enter in the search box Python, Choose Python Options :
Enter the code :
print(“Runoob”)
Right click mouse , Choose to run the file in an interactive window , If prompted to install extensions , Just click to install ( If there is no installation, it will always be displayed in the connection Python kernel ):
in addition , We can also open an existing file or directory ( Folder ), Let's open one runoob-test, You can also create one yourself :
And then we create one test.py file , Click the new file icon below , Input file name test.py:
Then you can write code , And then run ;
We installed the compiler , Let's start writing our first code :
# coding:UTF-8
infors=[1,2,3,4,5,6,7,8]
print("%d" % max(infors))
print("%d" % sum(infors))
print("%d" % (min(infors)))
print("%d" % (len(infors)))
print("%s" % (all(infors)))
print("%s" % any(infors))
# character string
# String fragmentation operation
del infors
infors="if i like you,i was The heart moves with it "
sun_name=infors[:5]
su_name=infors[4:]
print("%s" % (sun_name))
print("%s" % (su_name))
""" stay python Chinese characters and letters in a string are treated as one character . Chinese characters are two bytes , The letter is a byte , therefore , stay In the actual program , During string interception , Especially the interception of Chinese , You must record the number of bytes intercepted , Once the garrison is intercepted , There will be a problem of garbled code . """
''' UTF-8 code , English and English punctuation occupy one byte , Chinese characters and Chinese punctuation occupy three bytes . Unicode code ( Hexadecimal code ) Chinese and Chinese punctuation occupy two bytes , English also takes up two bytes . '''
# String information statistics
title="www.ccc.com"
print(" String length :%d" % (len(title)))
print(" The largest character in a string :%c" % (max(title)))
print(" The smallest character in a string :%c" % (min(title)))
# The use of member operators
if "www" in title:
print(" There is ")
# String formatting ;
name="lihua"
score=100
print(f"{
name} {
score}") #{} Used for occupying ;
print("%(name)s %(score)d" % vars()) # Dictionaries ;
''' grammar : “{ Member tag ! Transformation format : Format description }”.format( parameter list ) '''
del name
print("{name!s:^20}" .format(name="lihua"))
infors=12345678
print("{infors:,}".format(infors=12345678))
del infors
infors=190.456
print("{item:.2}".format(item=infors)) # Retain two digits of precision ;
Many of the above functions have not been introduced yet , This is just to familiarize you with the operation of the compiler , It will be described in detail later .
put questions to : In the above program, we will find , The program starts with “# coding:UTF-8” What does that mean ? What is his function ?
answer : In the computer world, all file information is stored on disk or transmitted through the network in the form of coding , Correct coding settings can prevent the occurrence of ” The statement “,Python In order to simplify the , Set it at the head :
# coding: Code name
Common code names are GBK,GB2312,UTF-8;
What is used here is UTF-8 code , Learn formally later Python Programming knowledge , Will introduce why to use UTF-8 code , Not the others .
This section mainly explains the compiler download , Skilled use of compilers can often save us time , If there is no foundation , You can follow the above tutorial step by step , Some people use psycharm compiler , It all depends on one's will , It will not affect the later study .
Project IntroductionThe online
Study Python There are many di