ParisGabriel:Python無止境 day02

來源:互聯網
上載者:User

標籤:字型   技術   bubuko   退出   arm   ls -l   gbk   演算法   tle   

ParisGabriel

    Python 入門基礎  補充:主流3操作大系統Windows:Winxp   Win7 Win8 Win10Unix:Solaris(SUN)

IOS(Apple移動端)

Mac OS

Linux  :(linux基於Unix 獨立出來的系統)

安卓(Android)

Ubuntu 16.04(當前教學版本)

ReadHat

CentOS

回顧:

Ctrl + Alt + Enter :虛擬機器全屏/退出全屏

Ctrl + Alt :釋放滑鼠

ctrl + shift + "+" : 終端字型放大

ctrl + "-" : 終端字型縮小

ctrl + d:退出終端

ctrl + l : 清屏

ctrl + c : 終止當前命令的執行

ctrl + s : 隱藏終端輸出

ctrl + q : 恢複終端輸出

init 0 : 關機

init 6 : 重啟

pwd:顯示當前的路徑位置

ls:查看當前位置有什麼內容

ls -l :以列表形式顯示

ls -a :顯示所有內容(包含隱藏)

cd:改變當前的工作路徑

cd 絕對路徑  :cd /home/tarena/aid1806/

cd 相對路徑

cd .. :回退到上一級目錄

cd    :回到使用者主目錄

mkdir:建立一個或者多個檔案

touch:建立一個或者多個文

tree:顯示分類樹

rm -r : 遞迴刪除檔案夾內所有內容

rm -f : 強制移除,不給任何提示

rm -i : 刪除前給提示(y代表yes,n代表no)

sudo:用超級使用者root的許可權執行一條命令

tar -zcvf 壓縮包名字.tar.gz 檔案夾/檔案:打包壓縮

tar -zxvf 壓縮包名字.tar.gz [-C 路徑]:解壓縮包

z : gzip對包進行壓縮

c : 建立包 create

x : 解包

v : 顯示操作的檔案細節 verbose

f : 檔案名稱 file

cp:複製檔案/檔案夾

mv:剪下 / 重新命名

 

練習1:

1、切換到目錄:/home/tarena/anaconda3/bin

2、查看當前所在的路徑

3、以列表形式列出當前路徑中所有內容(包含隱藏檔案或者目錄)

4、切換到當前路徑的上一級目錄

5、切換到 /etc 目錄,查看 /etc 有哪些內容

6、直接切換到使用者主目錄

答案:

[email protected]:~$ cd anaconda3/bin/[email protected]:~/anaconda3/bin$ pwd/home/tarena/anaconda3/bin[email protected]:~/anaconda3/bin$ ls -la總用量 27888drwxrwxr-x  2 tarena tarena   12288 7月  17  2017 .drwxrwxr-x 20 tarena tarena    4096 7月  17  2017 ..lrwxrwxrwx  1 tarena tarena       8 7月  17  2017 2to3 -> 2to3-3.6-rwxrwxr-x  1 tarena tarena     110 7月  17  2017 2to3-3.6-rwxrwxr-x  2 tarena tarena    3802 5月  26  2017 activate-rwxrwxr-x  1 tarena tarena     165 7月  17  2017 anaconda-rwxrwxr-x  1 tarena tarena     167 7月  17  2017 anaconda-navigator-rwxrwxr-x  1 tarena tarena     153 7月  17  2017 anaconda-project-rwxrwxr-x  1 tarena tarena   12003 7月  17  2017 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

  

練習2:

1、在使用者主目錄下建立目錄 mydir1 、mydir2

2、在mydir1下建立檔案:file1、file2、file3

3、將mydir1打包壓縮為mydir1.tar.gz,放在使用者主目錄下

4、將mydir1.tar.gz剪下到mydir1目錄下

5、將mydir1.tar.gz解壓縮,放到mydir2目錄下(-C選項)

答案:

[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    文檔core              my_env                                公用的  下載examples.desktop  pycharm-2017.1.5                      模板    音樂mydir1            pycharm-professional-2017.1.5.tar.gz  視頻    案頭mydir1.tar.gz     PycharmProjects                       圖片[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$ 

  

練習3:

1、在使用者主目錄下建立目錄:AI/Python/Linux

2、在Linux下建立檔案:linux1 、linux2

3、在Python下建立檔案:python1 、python2:

4、切換到AI目錄,查看當前所在路徑

5、直接切換到使用者主目錄

答案:

[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

  

練習4:

1、在使用者主目錄建立如下結構:PYTHON/Linux/day01

2、在 day01 下建立三個檔案:day01.txt day02.txt day03.txt

3、將 day03.txt 刪除

4、將 day02.txt 檔案時間更新為目前時間

5、在使用者主目錄下建立 python/Base

6、在Base下建立 day01 day02 day03 三個檔案夾

7、在day01下建立一個檔案 day01.txt

8、刪除 python/Base 檔案夾內的全部內容

答案:

[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

一、二進位

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

二進位演算法= 2**n-1 冪運算-1

· 十進位整數轉位元:“除以2取餘,逆序排列”(除二取 餘法)

89÷2 ……1 

44÷2 ……0

22÷2 ……0

11÷2 ……1

5÷2 ……1

2÷2 ……0

十進位整數轉八位元:

000 -> 0 | 004-> 4 | 010=8

001 -> 1 |005 -> 5| 011=9

002 -> 2 |006 -> 6 | 012=10

003 -> 3 |007 -> 7 | 013=11

十進位整數轉十六進位數:

0000 -> 0 0100 -> 4 1000 -> 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

二、編碼

Ascll碼 255個字元

Ascll碼錶每個字元統一佔用1個位元組

Ascll碼錶不支援中文

支援中文的第一張表   叫GB2312

1980年 GB3212  支援6700+字

1995年 GBK1.0  支援20000字

2000年 GB18030  支援27000字

unicode :萬國碼  (支援所有國家的編碼) 並且一個字元 統一佔用2個位元組

由於出於它的效率不高,對於儲存和傳輸來說都很耗資源。為了提高Unicode的編碼效率,於是就出現了UTF-8編碼

UTF-8   、

UTF-8是 unicode的擴充集  英文佔一個位元組 東南亞 歐洲國家2個位元組  中文3個位元組

Assic --> GB2312 --> GBK1.0 --> GB18030 --> unicode --> UTF-8

Unicode是可以向下相容GB2312、GBK 、GB17030
而UTF8 重新劃分分類和次序 不再是原來的次序編碼

#!-*-coding:utf-8 -*- (聲明使用utf8編碼)
#codig:utf-8(聲明使用utf8編碼)

print u“我愛北京天安門?”(u代錶轉換Unicode格式)轉換編碼 列印

 

 

ParisGabriel:Python無止境 day02

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.