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

[Python] Introduction to Silicon Valley Python zero Foundation

編輯:Python

Just remember this ~

【Python】 Silicon Valley Python Zero Basics

1-10

Configure the role of environment variables ~

  • In our daily use of the command line whatever The apple system is still linux still win They all use ~

If you just write a command such as asb What happens ?

image-20220623182050333

win Is the error message an internal instruction ~

Then why can some content be found ~

  • It's actually because When our content can't be found in the directory of that year, we will go to -> User environment variable -> Environment variables of the system

  • We just set the environment variable ~ such as js Of node vpn vpm~ You will find that you can use it directly ?

  • It's actually because I found that folder ~ Found the command ~ Told the computer what to do ~

A few notes :

  • path It's case insensitive ~ Path PATH All right
  • mac After modification, you need to apply ,win Just reopen the window

Binary Introduction

I believe many people know the decimal system

  • That is, full decimal 1; Everyone we call A hundred thousand ... I'll draw a picture
  • The analogy of the two-level system is full 2 Into the 1, So name it in decimal 2 Every digit of the base is 2,4,8,16
image-20220624155115075

So binary from 0 Start writing How to write ? 0,1, 10, 11, 100,101, 110, 111 , 1000, 1001, 1010 This is it. 0-10

So how do you think ?

Watch it ~ Everyone has only 0/1 1 Go up 1 If the next one is 0 It becomes 1 ; If it is 1 Just go into 0, Then the next bit continues to detect ~

( For those who have studied, you will find a very simple recursion ~

recursive : It is also called self recursion , It's calling itself , Always the same ~

Iteration is , The result of the last time will be used in the next time ~

for instance : Growth is iteration , Every year there will be changes that will affect the future , Recursion is playing games moba game , Or just say gobang , The result of the last time does not affect this time . Let's understand this first. There are many details

)

So what do you think of a 2 Into the system is 10 Decimal number ?

Let's talk about it first , commonly 2 Hexadecimal system will have a position occupation , Is similar to Contents after decimal point There will be 0 placeholder . Binary will also have... In the integer part ~

This is called Static storage space static store, There will be dynamic Of dynamic store, It will change ~ similar The shell of a tortoise ~ As the tortoise grows bigger, so does its shell , Static is equivalent to your own clothes , I'm fat eating by myself Clothes don't change , It's just tight ~

Such as it Four place , How many are the four ? 2 Of 3 Power 8 therefore The fourth place has 1 Namely 8 The number above , But it won't be 8 Of Double similar ( Thousand bit There are values on The maximum value is 9999 It can't be 10000 That's ten times )

0001 1 2 Of 0 Power =1

0010 2 The second is 2 Of 1 Power = 2

0011 3 2 The first power of + 2 Of 0 Power = 3

0100 4 2 The second power of = 4

0101 5 Two 2 Power +2 Of 0 Power = 5

0110 6

0111 7

1000 8

1001 9

1010 10

Forget it ? That position has 1 Just Use the current position -1 As 2 The index of plus that will do ~

Mathematics is really hard to tell .... Embarrassed the math teacher ...

Why don't I write here 2^3 = 8 Because This ^ In mathematics, it represents Power But in Computer languages are bit operations ~

For example, programmers can't write 2×3=6 Can write 2*3 = 6

data storage

This is the data 010101010 Composed of ~ But it will not be too little. Generally speaking, a number will be expressed in tens of digits ,( It doesn't unfold ~)

All arrays exist in binary form in the computer , I remember a description is diode ~ Can only off perhaps on off by 0 on by 1

Or like a small lattice ~ Can be stored 0/1

  • Then each cell exists in the memory ~, We call it 1bit( position ) The bit

bit Is the smallest unit in a computer ,

8 individual bit Form a byte byte

byte Is the smallest computer Operable units ~ You can open a folder to see its size ~ Whatever you do , He can only change at least 1 byte , Will not appear to you 0.1 Bytes in this case ~

Therefore, there is the following conversion

8bit = 1 byte

1024 byte = 1 Kb(yte) kilobytes

1024 kb = 1 mb

1024mb = 1gb

1024gm = 1tb

Now? b Are directly omitted ~

Generally, binary will not be displayed directly , Will use 16 To display ~ Hexadecimal More than the decimal system abcedf

image-20220624162913424

This one is called Binary Viewer Software for , You can open any file Displayed as binary ~

Rest assured that no one will understand .... Maybe the strongest brain can

Insert a digression , There are a group of super intelligent people in China ~ Not all are doing research , There are... In all walks of life

They belong to a well-known group in the circle ~ within a circle ! They rated the strongest brain as --- Develop brain proficiency .

Just like the oil man we learned when we were young ~ It's hand eye proficiency , The strongest brain is Proficiency in using the brain , Always cultivate a certain area of the brain , This area will be especially powerful ~ however Other aspects will not be much more than ordinary people ~ It is still the category of ordinary people ~

The group mentioned above can search on Baidu , When we don't train, we are 5 Now After training, you may achieve 20 Those on the show may be training themselves , And can reach super high people such as 70. So these people I'm talking about may be in 50.

High IQ Association ? Forget the

Text and character set

  • The text is divided into Pure text and Rich text ~

  • Plain text can only hold one type of text content , Can't save extraneous content ( typeface , Color , picture )

  • Rich text can save something other than text , Software example word file pdf

  • At development time , The program is written in plain text ~( It would be awesome if you could develop with pictures ... Put a picture on it and directly generate plain text ..., Then add audio development ,hhh)

  • Plain text is converted to at the bottom of the computer 2 Hexadecimal code ~

    • Since it can be converted, it needs an agreement ? Rules ?
      • Character conversion binary is called --- code
      • Binary conversion characters are called --- decode
    • The rules followed by encoding and decoding are called character sets ~
  • Common character sets :

    • ASCII

      • American
      • Is the total 128 Seven But it must occupy one byte The highest bit is 0
      • Case write + A pile of symbols altogether 128 individual Quite enough ~

      Followed by Roman numerals 2, And then there was ASCII Expand Expanded 1 position 2 Of 8 Power = 256 But many languages can't put everything in 256 This code is not used in bits ~

    • ISO-8859-1

      • European Code
      • Is the total 256 8 position
    • GB2312

    • GBK

      • The above two are both in Chinese , There is nothing special , My name is a rare word ~ At first there was no , It's all added ~
    • Unicode

      • unicode ~ Contains all the languages and symbols
      • You can baidu Unicode, Look at your name ~
      • Unicode There are many implementations , Include UTF-8 UTF-16 UTF-32
        • UTF-8 It's getting longer May be 1-5 Bytes to represent a character
        • UTF-16 yes 2-4
        • UTF-32 Is constant 4 Bytes
        • It's usually UTF-8

The statement

The above understood words Think about why the garbled code phenomenon ?

  • It is not a rule to decode and encode ~
  • So if there is garbled code, check whether the character set is the same ~

Computer language

Computer languages are divided into machine language , Semiotic language ( assembly language ), High-level language . Computer language is talking to computers ~

  • machine language :

    • The binary
    • Efficient execution but not easy to write
  • assembly language :

    • Know that the machine is not easy to write , Then it's just a little easier to write , Replace part of machine language with symbols ~ Then the symbols are converted into machine language
    • This process is called assembly assembling, The process of turning back is called disassembly disassembling
    • Better write some , The execution efficiency is not so slow ~
    • Assembly language can only be applied to some hardware , Poor compatibility ~
  • High-level language :

    • Just like that. python This kind of language is better understood and learned . But it will be less efficient ~ So the chain of disdain appears in high-level languages ~
    • The closer to the assembly, the higher the learning cost, such as c derivatives ~hhh doge. At the top of the chain of disdain . Of course, the big guys who play these games usually don't bully the rest of us
    • Grammar is similar to English , But the connection with hardware is not so close ~
    • C C++ C# Java python js

Introduce what is interpreted language and compiled language

  • High level languages also need to be converted into machine code and then executed

Pay attention to this , I remember mentioning in the university that , High level languages need to be converted into assembly and then into machine code ~ In fact, there is no need to convert to assembly language at all , There is no need to compile as a bridge ~ High level languages are translated into opcode The efficiency of machine code is also very fast and accurate

According to the timing of the conversion ~ Language is divided into interpretive language and compiled language

  • Compiler language

    • C Language ,
    • Compile the code into before the code is executed opcode And then let the computer handle it
    • Execution speed special fast
    • But poor compatibility , For example win Compiled in mac The system cannot be used , stay linux Compiled in win I can't use ~
  • Explanatory language

    • Python Javascript Java
    • The code parses as it executes
    • The speed will be relatively slow , But cross platform will be good

    To put it bluntly, it is a precompiled , An implementation is bound to be slow during compilation ~ Cross platform depends on the interpreter ~ So where is the difference between speed ? The efficiency of the interpreter will determine the execution rate to some extent ~

java It's interpreted language ,Java It's compiled first class file , Re pass JVM Explain to perform , It's an interpretative language

use python Some gadgets you must know

  • python Inventor Guido Guido Gui Uncle GUI ~ It is called this name in China

    • 19 Retired in senseless 20 Joined Microsoft in 1996
  • There is a saying. ''Life is short I use Python' Life is too short for me python

  • python The design of the schedule

image-20220624183801795

Write a few Python Use of :

Count as flag Well , I will play it all for the last time ~ After all, Kudo doesn't have to do it himself ~2333

  • Web application
  • Reptiles
  • Scientific Computing
  • Automatic operation and maintenance
  • big data
  • Cloud computing
  • Ai
  • game ( This is not done )

python Environment building

To put it bluntly, setting up an environment is to install an interpreter ~

python There are many versions of the interpreter for

  • CPython( official )
    • use C Written language
  • Pypy
    • use python Written python Interpreter
  • IronPython
    • use .net Written
  • Jython
    • Java Written

python edition

python There are two big versions

2.x and 3.x

There is a difference here ,

  • This version does not say 3.x It's better than 2.x The best ~ The two of them are parallel All in use

  • 3.x And 2.x Are incompatible with each other ~

I must learn something new ~ So the following syntax is 3.x The grammar of ~

OK install Python

I'm using mac, So use homebrew download ~

  • homebrew yes mac Our package management tools are very powerful ~

Homewbrew download

The terminal can input this sentence , I've been looking for a long time ! Pay attention to the execution process , Very meticulous ~

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

After installation, you need to configure the domestic image ~ Just choose ~

Then install python Version management tools , because python There are many versions ~ Switching is troublesome. With this switch, just enter a code ~

brew install pyenv
pynev install 3.10.0

that will do ~

Input python Later >> Proof of successful installation ~

It's called entering python The interaction mode of

image-20220624233609222

win That's true

image-20220624233824884
  • mac That's true , You can see that I have entered python

  • The version is mac Self contained version 2.7

  • How can I cut it into the ones I downloaded ? Use the version control tool

  • Enter this command to exit interactive mode

image-20220624233938821
image-20220624234313682
pyenv global 3.10.0

that will do

We certainly don't use terminal development ~ Write small demo It won't be here , Find a web page to edit online python All good. ~

ok It's here today ~


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