First, bytes type
Two or three-dollar operation
1 |
result = value 1 if condition else value 2 |
If the condition is true: result = value 1
If the condition is false: result = value 2
Third, the binary
- Binary, 01
- Octal, 01234567
- Decimal, 0123456789
- Hex, 0123456789ABCDEF binary to 16 binary conversion http://jingyan.baidu.com/album/47a29f24292608c0142399cb.html?picindex=1
Computer memory address and why use - into the system?
Why use - in-process
1, the computer hardware is 1012 binary, 16 binary is just a multiple of 2, it is easier to express a command or data. Hex is shorter, because a 16 binary number can be the top 4 bits 2 binary number, that is, one byte (8 bits can be represented by two 16) in the conversion.
2, the earliest provisions of the ASCII character set is the use of 8bit (late expansion, but the basic unit or 8bit), 8bit with 2 16 directly can express, whether reading or storage is more convenient than other systems
3, the computer CPU operation is also in accordance with the ASCII character set, 16, 32, 64 in such a way in the development, so the data exchange when the 16 system also appears better
4, in order to unify the specification, CPU, memory, hard disk we see are used in the 16 binary calculation
- where to use the binary
1, network programming, data exchange needs to parse bytes is a byte of a byte processing, 1 byte can be used 0xFF two 16 binary to express. With the network capture, you can see that the data is transmitted via 16-binary.
2, data storage, storage in the hardware is 0101 of the way, stored in the system is expressed in the form of a byte
3, some common values of the definition, such as: We often use the HTML in the color expression, is the use of the 16-way, 4 16-bit can express a good millions of color information.
Four, All Objects
for Python , all things are objects, objects are created based on classes
Therefore, the following values are objects: "Wupeiqi",38,[' Beijing ', ' Shanghai ', ' Shenzhen ' ), and are objects generated from different classes.
Switching between python2.7 and version 3.5 in Pycharm
Toggle PY Version
File-Settings->project interpreter-Select version
Program replication with Ctrl+d
Add # to the front, CTRL +?
Cancel Ctrl + Z
If the password is ciphertext, you need to use Python's
In Pycharm input:
Import Getpass
# NAME = input (' Input your Name: ')
# age = input (' Input your: ')
#
# Print (name,age)
Username = input ("username:")
Password = getpass.getpass ("Password:")
. is the function of calling Getpass
Find the password or see, but run input cmd on the computer, enter:
C:\users\user\python36>pythonc:\users\user\pycharmprojects\py_fullstack_s4\20180106\ Interactive program. py
Successful execution
View data types
Pirnt (Type (name), type (age))
Data of the same data type can be added or compared, otherwise it cannot be
Conversion type int ()
STR ()
ASCII 256 8 bit
BITS is 8-bit 8bits
1 2 4 8 16 32 64 128 256
1 1 1 1 1 1 1 1 1
1 bytes = 8 bit =8bits=1byte
1024x768 byte=1kb
1024kb=1mb=100 million bytes = 1 million characters
1024mb=1gb= a high-definition short film
1024gb=1tb
1024tb=1pb
1 binary is the smallest representation unit in a computer
1 bytes is the smallest storage unit in a computer
Unicode Universal Code
Accounted for 32 bits utf-32 = 4 bytes
Because it takes up too much
Utf-8=8bits Variable length Encoding
This English account for one byte, Chinese 3 bytes
Europe 2 bytes
#是整行注释, do not perform
""" is a multiline comment that turns the inside into a string
Single and double quotes are no different, only for single line, 3 quotation marks can be used for multiple lines of string or comment
Numeric type
Str character
Number Type
int integral type
Long length integer 2**32 results automatically with L (32-bit hard disk or 32-bit software, will appear 2**32 results automatically with L, only 64 bit at the same time, will not take L)
float Float Type
Plural
Boolean distribution
Condition set to True
Condition not valid, false
String Common functions:
" \n\t \ t"
Print (name)
# take off, put the front and back space, \t\n off
# Split , dividing a character by a space by default as a list type
" \n\t \ t"
Print (Name.split (";" # split, dividing a character by a space by default into a list type, you can specify a delimiter
Length
name1="Jensen,zhicong,lizhi"
Print (Name1.index ("h" Index
# extract only a subset of the information in a string called slices
Print (Name1[0:6])
Print (name1[7:14])
Print (name1[-5:])
Print (Name1[0::2]) #2 is the length of the cut
Print (Name1[0::1])#2 is the length of the cut
Replace
name = ["A","B","C","D","E"]
Print (name)
Print (Name.index ("D"))
Name[name.index ("D")]="DD"
Print (name)
name = [] # List
Print (name)
Print (Type (name))
name = [" Soho"," qin"," li Zhi"," li Zhi"," Swallow "]
Print (name)
Print (Name[-1])
Print (Name.index (" li Zhi")) # Query the location of the Li Zhi, the subscript of the element
# Want to take all the qin behind
Print (name[1:])
# count the number of Li Zhi
Print (Name.count (" li Zhi"))
# Append
Name.append (" Bald")
Print (name)
# Insert, at the back of the 2nd
Name.insert (2," Corn")
Print (name)
# Delete 4th
Print (Name.pop (2))
Print (name)
Getting Started with Python