Parisgabriel
basics of getting started with Python
Add:Mainstream 3 operating large system WINDOWS:WINXP Win7 Win8 Win10unix:solaris (SUN)
IOS (Apple Mobile)
Mac OS
Linux: (Linux-based UNIX-independent system)
Android (Android)
Ubuntu 16.04 (current teaching version)
Readhat
Centos
Review:
Ctrl + Alt + Enter: Virtual machine Full Screen/exit full screen
Ctrl + Alt: Release mouse
CTRL + SHIFT + "+": Terminal font magnification
CTRL + "-": Terminal font reduction
CTRL + D: exiting the terminal
CTRL + L: Clear screen
CTRL + C: Terminates execution of the current command
CTRL + S: Hide terminal output
CTRL + Q: Restore terminal output
Init 0: Shutting down the machine
Init 6: Restart
PWD: Displays the current path location
LS: See what's in the current location
Ls-l: Display in list form
LS-A: Show All content (contains hidden)
CD: Change the current work path
CD absolute path: cd/home/tarena/aid1806/
CD relative path
Cd.. : Fallback to the top level directory
CD: Back to User home directory
mkdir: Create one or more files
Touch: Create one or more text
Tree: Show Directory tree
Rm-r: Recursively delete all contents in a folder
Rm-f: Force delete without giving any hint
Rm-i: Prompt before deletion (y means yes,n on behalf of NO)
sudo: Execute a command with Superuser root privileges
TAR-ZCVF compressed package name. tar.gz Folder/file: Packed compression
TAR-ZXVF compressed package name. tar.gz [-C Path]: Unpack Package
Z:gzip to compress a package
C: Creating a package Create
X: Unpacking
V: Displays the file details of the operation verbose
F: FileName File
CP: Copy files/folders
MV: Cut/Rename
Exercise 1:
1. Switch to directory:/home/tarena/anaconda3/bin
2. View the current path
3. List all the contents of the current path (including hidden files or directories)
4. Switch to the top-level directory of the current path
5. Switch to/etc directory to see what the/etc content is
6. Switch directly to the user's home directory
Answer:
[Email protected]:~$ cd anaconda3/bin/[email protected]:~/anaconda3/bin$ pwd/home/tarena/anaconda3/bin[email protected]:~/anaconda3/bin$ Ls-la Total dosage 27888drwxrwxr-x 2 tarena tarena 12288 July . drwxrwxr-x 20 Tarena Tarena 4096 July 2017.. lrwxrwxrwx 1 Tarena tarena 8 July 2to3-2to3-3.6-rwxrwxr-x 1 Tarena tarena 110 July 2to3-3.6-rwxrwxr-x 2 tarena tarena 3802 May activate-rwxrwxr-x 1 Tarena Tarena 165 July anaconda-rwxrwxr-x 1 Tarena tarena 167 July 2017 Anaconda-navigator-rwxrwxr-x 1 Tarena tarena 153 July anaconda-project-rwxrwxr-x 1 Tarena Tarena 12003 July asadmin[email protected]:~/anaconda3/bin$ CD. [Email protected]:~/anaconda3$ cd etc/[email protected]:~/anaconda3/etc$ lsdbus-1 fish fonts jupyter rc.d[email protected]:~/anaconda3/etc$ CD
Exercise 2:
1. Create directory Mydir1, Mydir2 in user's home directory
2. Create a file under Mydir1: File1, File2, File3
3, Mydir1 packaging compression to mydir1.tar.gz, placed in the user's home directory
4. Cut the mydir1.tar.gz into the Mydir1 directory
5. Unzip the mydir1.tar.gz into the Mydir2 directory (-c option)
Answer :
[email protected]:~$ mkdir mydir1 mydir2[email protected]:~$ cd mydir1[email protected]:~/mydir1$ Touch file1 file2 file3[email protected]:~/mydir1$ CD. [email protected]:~$ TAR-ZCVF mydir1.tar.gz mydir1mydir1/mydir1/file3mydir1/file1mydir1/file2[email protected]:~$ Lsanaconda3 mydir2 Yang document Core my_env public download Examples.desktop pycharm-2017.1.5 template Music Mydir1 Pycharm-professio nal-2017.1.5.tar.gz video Desktop mydir1.tar.gz pycharmprojects pictures [email protected]:~$ mv Mydir1 . tar.gz mydir1[email protected]:~$ cd mydir1[email protected]:~/mydir1$ lsfile1 file2 file3 mydir1.tar.gz[ email protected]:~/mydir1$ TAR-ZXVF mydir1.tar.gz-c ~/mydir2mydir1/mydir1/file3mydir1/file1mydir1/file2[ email protected]:~/mydir1$ CD ~/mydir2[email protected]:~/mydir2$ lsmydir1[email protected]:~/ mydir2$ CD mydir1/[email protected]:~/mydir2/mydir1$ lsfile1 file2 file3[email protected]:~/mydir2/mydir1$
Exercise 3:
1. Create directory under User's home directory: Ai/python/linux
2. Create files under Linux: Linux1, linux2
3. Create a file under Python: Python1, Python2:
4. Switch to the AI directory to see the current path
5. Switch directly to the user's home directory
Answer :
[Email protected]:~$ mkdir-p ai/python/linux[email protected]:~$ cd ai/python/linux[email protected]:~/AI/python/ linux$ Touch linux1 linux2[email protected]:~/ai/python/linux$ CD. [Email protected]:~/ai/python$ touch python1 python2[email protected]:~/ai/python$ CD ~/ai[email protected]:~/ai$ CD
Exercise 4:
1. Create the following structure in the user's home directory: PYTHON/LINUX/DAY01
2. Create three files under Day01: Day01.txt day02.txt day03.txt
3. Delete the Day03.txt
4. Update the Day02.txt file time to the current time
5. Create the python/base in the user's home directory
6. Create a day01 day02 day03 three folders under base
7. Create a file under Day01 day01.txt
8. Delete all contents in Python/base folder
Answer :
[Email protected]:~$ mkdir-p python/linux/day01[email protected]:~$ cd python/linux/day01[email protected]:~/PYTHON/ linux/day01$ Touch day01.txt day02.txt day03.ttx[email protected]:~/python/linux/day01$ rm-rf day03.txt[email protected]:~/python/linux/day01$ Touch day02.txt[email protected]:~/python/linux/day01$ mkdir-p ~/python/base[email protected]:~/python/linux/day01$ Pwd/home/tarena/python/linux/day01[email protected]:~/python/linux/day01$ Lsday01.txt day02.txt day03.ttx[email protected]:~/python/linux/day01$ cd ~/python/base[email protected]:~ /python/base$ mkdir day01 day02 day03[email protected]:~/python/base$ cd day01[email protected]:~/python/base/day01$ Touch day01.txt[email protected]:~/python/base/day01$ cd[email protected]:~$ rm-rf python
One or two binary
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0=0 1=1 2=10 3=11 4=100 5=101 6=110 7=111 8=1000 9=1001 .... 127=1111111
Binary algorithm = 2**n-1 Power operation-1
· Decimal integer to binary number: "Divided by 2 to get the remainder, reverse order" (except for the second method)
89÷2 ... 1
44÷2 ... 0
22÷2 ... 0
11÷2 ... 1
5÷2 ... 1
2÷2 ... 0
Decimal integer to octal number:
0 | 004-> 4 | 010=8
001, 1 |005, 5| 011=9
002, 2 |006, 6 | 012=10
003, 3 |007, 7 | 013=11
Decimal integer to hexadecimal number:
0000, 0 0100, 4, 8, 1100, C
0001 1 0101, 5 1001, 9 1101, D
0010, 2 0110, 6 1010, A 1110, E
0011, 3 0111, 7 1011, B 1111, F
Second, the Code
ASCLL Code 255 characters
ASCLL Code table each character occupies a uniform 1 bytes
ASCLL Code table does not support Chinese
The first table supporting Chinese is called GB2312
1980 GB3212 Support 6700+ Word
1995 GBK1.0 Support 20000 words
2000 GB18030 Support 27000 words
Unicode: Universal code (supports all country codes) and a single character occupies 2 bytes uniformly
Because It is inefficient, it is resource-intensive for storage and transport. In order to improve the encoding efficiency of Unicode, a UTF-8 encoding is presented.
UTF-8,
UTF-8 is an extension set of Unicode English accounting for one byte Southeast European countries 2 bytes Chinese 3 bytes
Assic--GB2312---GBK1.0--GB18030
Unicode can be backwards compatible with GB2312, GBK, GB17030
and UTF8 the classification and order is no longer the original sequence encoding
#! -*-coding:utf-8-*-(declaration using UTF8 encoding)
#codig: utf-8 (declaration using UTF8 encoding)
Print U "I love Beijing Tian ' an gate?" "(U for convert Unicode format) Convert encoded print
Parisgabriel:python Endless day02