- 远程连接:
- 登陆远程,在.ssh目录下创建authorized_keys
- 把自己主机上通过ssh-keygen创建的id_rsa_pub中的内容复制到远程的authorized_keys中
- 文件分类:
文本文件 打开后自动解码为字符,比如txt,word,py程序文件
二进制文件 b’\xe4\xbd\xa0\xe5\xa5\xbd’ 无法通过文字编码解析,比如压缩包,音频,视频,图片
字节串类型: 表达二进制数据的一种类型
字节串类型演示 bytes * 所有字符串都能转换为字节串
并不是所有的字节串都能转换为字符串:字符串一定是文本编码格式,二进制不一定都在文本编码范围内
定义一个字节串数据
b1 = b"hello world" # 英文字符
print(type(b1))
b2 = "你好".encode() # utf8字符定义为字节串
print(b2)
s = "hello ,死鬼"
b3 = s.encode() # 变量使用encode转换
print(b3)
字节串转换为字符串
print("转换为字符串:",b'hello ,\xe7\xcd\xfb\xe9\xac\xbc'.decode())
- ubuntu安装后的残留包位置:/var/cache/apt/archives
清除所有残留包:sudo apt clean *
> -vi命令 功能
yy 复制一行,可以 nyy 复制多行
dd 删除光标所在行,可以 ndd 剪切多行
p 粘贴
-
安装本地包
sudo dpkg -i xxxx.deb -
解决依赖关系
sudo apt --fix-broken install -
os模块
- os.path.exists
- os.path.getsize
- os.listdir
- os.path.isfile
- os.remove
‘a’.encode()
b'a'
‘你好’.encode()
b'\xe4\xbd\xa0\xe5\xa5\xbd'
‘你好’.encode(‘utf-8’)
b'\xe4\xbd\xa0\xe5\xa5\xbd'
‘你好’.encode(‘gbk’)
b'\xc4\xe3\xba\xc3'
b’\xc4\xe3\xba\xc3’.decode(‘gbk’)
'你好'
- 正则表达式
- re.findall(表达式,目标)
- re.findall(‘ab|cd’,‘abcdacbcadacabcd’)
- re.findall(‘a.c’,‘abcahcauc’)
- re.findall(‘ab’,‘ababcdab’)
- In [13]: re.findall('[0-9A-Z]','How 9 8 are you ')
Out[13]: ['H', '9', '8']
- In [10]: re.findall('[aeiou]','how are you')
Out[10]: ['o', 'a', 'e', 'o', 'u']
- In [11]: re.findall('[A-Z]','How are you')
Out[11]: ['H']
- In [15]: re.findall('[^0-9]','323jfasdfj3435')
Out[15]: ['j', 'f', 'a', 's', 'd', 'f', 'j']
- In [16]: re.findall('[^0-9]','323jfasd fj3435')
Out[16]: ['j', 'f', 'a', 's', 'd', ' ', ' ', ' ', 'f', 'j']
- In [17]: re.findall('ab|bc','abc')
Out[17]: ['ab']
- In [18]: re.findall('[a-z]','abcdefg')
Out[18]: ['a', 'b', 'c', 'd', 'e', 'f', 'g']
- In [19]: re.findall('[a-z][a-z]','abcdefg')
Out[19]: ['ab', 'cd', 'ef']
- In [20]: re.findall('..','abcdefg')
Out[20]: ['ab', 'cd', 'ef']
- In [21]: re.findall('^jame','jame,hello')
Out[21]: ['jame']
- In [22]: re.findall('^jame','hello,jame')
Out[22]: []
In [24]: re.findall('jame$','jame,hello')
Out[24]: []
In [25]: re.findall('jame$','hello,jame')
Out[25]: ['jame']
In [26]: re.findall('^jame$','jame')
Out[26]: ['jame']
In [31]: re.findall('a[a-z]*','abcabd7ab8acs')
Out[31]: ['abcabd', 'ab', 'acs']
In [4]: re.findall('[0-9][0-9]*','小明,身高177cm,体重48kg')
Out[4]: ['177', '48']
In [8]: re.findall('W[a-z]+','WabWWacW,Wc')
Out[8]: ['Wab', 'Wac', 'Wc']
In [9]: re.findall('-?[0-9]+','jame,age:18,-34')
Out[9]: ['18', '-34']
In [5]: re.findall('\w+','server_port= 8888')
Out[5]: ['server_port', '8888']
In [6]: re.findall('\W+','server_port= 8888')
Out[6]: ['= ']
In [7]: re.findall('\w+\s+\w+','hello world')
Out[7]: ['hello world']
In [8]: re.findall('\w+','hello world')
Out[8]: ['hello', 'world']
In [9]: re.findall('\S+','hello world')
Out[9]: ['hello', 'world']
In [10]: re.findall('\S+','he-llo world')
Out[10]: ['he-llo', 'world']
In [11]: re.findall('\w+','he-llo world')
Out[11]: ['he', 'llo', 'world']
In [15]: re.findall(r'\bis\b','This is a test')
Out[15]: ['is']
In [16]: re.findall(r'\Bis\b','This is a test')
Out[16]: ['is']
In [2]: re.findall("-?\d+\.\d+","1.23,123,234,2.34,12,34,12.32")
Out[2]: ['1.23', '2.34', '12.32']
In [3]: re.findall("-?\d+\.?\d+","1.23,123,234,2.34,12,34,12.32")
Out[3]: ['1.23', '123', '234', '2.34', '12', '34', '12.32']
In [4]: re.findall(r'\(.+?\)',"(abcd)efgh(higk)")
Out[4]: ['(abcd)', '(higk)']
In [5]: re.findall(r'\(.+\)',"(abcd)efgh(higk)")
Out[5]: ['(abcd)efgh(higk)']
In [8]: re.search(r'(王|李)\w{1,3}','望着荣耀,王者荣耀').group()
Out[8]: '王者荣耀'
In [6]: re.search(r'(ab)+',"ababababab").group()
Out[6]: 'ababababab'
In [9]: re.search(r'(?P<pig>ab)+',"ababababab").group()
Out[9]: 'ababababab'
In [10]: re.search(r'(?P<pig>ab)+',"ababababab").group('pig')
Out[10]: 'ab'
In [13]: re.search(r'(1[0-9]{10})\D+','17801051806是我的电话').group
...: ()
Out[13]: '17801051806是我的电话'
In [14]: re.search(r'(?P<tel>1[0-9]{10})\D+','17801051806是我的电话'
...: ).group()
Out[14]: '17801051806是我的电话'
In [16]: re.search(r'(?P<tel>1[0-9]{10})\D+','17801051806是我的电话'
...: ).group('tel')
Out[16]: '17801051806'
In [17]: re.findall(r'(ab)',"ababab")
Out[17]: ['ab', 'ab', 'ab']
In [18]: re.findall(r'(ab)\d+',"ababab")
Out[18]: []
In [19]: re.findall(r'(ab)\d+',"ab1abab")
Out[19]: ['ab']
- sudo service mysql status
- sudo service mysql start
- mysql -uroot -p123456
- show databases;
- mysql -h 主机地址 -u 用户名 -p
- create database dlk character set utf8;
- use dlk
- select database()
- drop database dlk
- TINYINT 1
- SMALLINT 2
- MEDIUMINT 3
- INT 4
- BIGINT 8
- FLOAT 4
- DOUBLE 8
- DECIMAL (M,D)