Capsule
2020-03-02 10:00:00 +0800
Python
1. python数组反转
list(reversed(a)) #reversed(a)返回的是迭代器,所以前面加个list转换为list
sorted(a,reverse=True)
a[: :-1] #其中[::-1]代表从后向前取值,每次步进值为1
2. 类继承 class 关键字
- 使用 class 关键字修改实例的类型引用
Linux
1. proc目录下cpuinfo检查
查看 CPU 物理个数
grep 'physical id' /proc/cpuinfo | sort -u | wc -l
查看 CPU 核心数量
grep 'core id' /proc/cpuinfo | sort -u | wc -l
查看 CPU 线程数
grep 'processor' /proc/cpuinfo | sort -u | wc -l
查看 CPU 型号
dmidecode -s processor-version
查看 CPU 的详细信息:
cat /proc/cpuinfo
2. CentOS 7 修改时区
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# timedatectl list-timezones # 列出所有时区
# timedatectl set-timezone Asia/Shanghai # 设置系统时区为上海
# timedatectl set-local-rtc 1 # 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间
3. iptables基础
iptables -t nat -L
4. 在ls中列出文件的绝对路径
ls | sed "s:^:
pwd/:"
#在所有行之前/后加入某个字符串
sed 's/^/string/g' file
sed 's/$/string/g' file
find $PWD -maxdepth 1 | xargs ls -ld
# 列出当前目录下的所有文件(包括隐藏文件)的绝对路径, 对目录不做递归
find $PWD | xargs ls -ld
# 递归列出当前目录下的所有文件(包括隐藏文件)的绝对路径
Windows
1. Windows下的TCP连接检查
netstat -ant | findstr
window下查看TCP端口连接情况:netstat -ano -p tcp findstr 8080