kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

python xlsx读取oldval, 转xls、csv

xlsx读取oldval, 转xls

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#coding:utf-8
import xlrd
import xlwt
import sys

if len(sys.argv) != 3:
	print 'python export.py xlsx sheet'
	exit(1)

filename = sys.argv[1]
sheetname = sys.argv[2]

data = xlrd.open_workbook(filename)
#table = data.sheet_by_index(0)
table = data.sheet_by_name(sheetname.decode('utf-8'))

workbook = xlwt.Workbook(encoding = 'utf-8')
worksheet = workbook.add_sheet(sheetname)

for rn in range(table.nrows):
	line = table.row_values(rn)
	j = 0
	for v in line:
		worksheet.write(rn, j, line[j])
		j = j + 1

# 保存数据到硬盘
workbook.save((filename+'.xls'))

excel转换为csv

https://www.jb51.net/article/164478.htm

1 pandas
1
2
3
import pandas as pd
data = pd.read_excel('123.xls','Sheet1',index_col=0)
data.to_csv('data.csv',encoding='utf-8')
2 xlrd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python 
__author__ = "lrtao2010"
'''
Excel文件转csv文件脚本
需要将该脚本直接放到要转换的Excel文件同级目录下
支持xlsx 和 xls 格式
在同级目录下生成名为excel_to_csv.csv 的文件,采用UTF-8编码
'''
import xlrd
import csv
import os
#生成的csv文件名
csv_file_name = 'excel_to_csv.csv'
def get_excel_list():
  #获取Excel文件列表
  excel_file_list = []
  file_list = os.listdir(os.getcwd())
  for file_name in file_list:
    if file_name.endswith('xlsx') or file_name.endswith('xls'):
      excel_file_list.append(file_name)
  return excel_file_list
def get_excel_header(excel_name_for_header):
  #获取表头,并将表头全部变为小写
  workbook = xlrd.open_workbook(excel_name_for_header)
  table = workbook.sheet_by_index(0)
  #row_value = table.row_values(0)
  row_value = [i.lower() for i in table.row_values(0)]
  return row_value
def read_excel(excel_name):
  #读取Excel文件每一行内容到一个列表中
  workbook = xlrd.open_workbook(excel_name)
  table = workbook.sheet_by_index(0) #读取第一个sheet
  nrows = table.nrows
  ncols = table.ncols
  # 跳过表头,从第一行数据开始读
  for rows_read in range(1,nrows):
    #每行的所有单元格内容组成一个列表
    row_value = []
    for cols_read in range(ncols):
      #获取单元格数据类型
      ctype = table.cell(rows_read, cols_read).ctype
      #获取单元格数据
      nu_str = table.cell(rows_read, cols_read).value
      #判断返回类型
      # 0 empty,1 string, 2 number(都是浮点), 3 date, 4 boolean, 5 error
      #是2(浮点数)的要改为int
      if ctype == 2:
        nu_str = int(nu_str)
      row_value.append(nu_str)
    yield row_value

def xlsx_to_csv(csv_file_name,row_value):
  #生成csv文件
  with open(csv_file_name, 'a', encoding='utf-8',newline='') as f: #newline=''不加会多空行
    write = csv.writer(f)
    write.writerow(row_value)
if __name__ == '__main__':
  #获取Excel列表
  excel_list = get_excel_list()
  #获取Excel表头并生成csv文件标题
  xlsx_to_csv(csv_file_name,get_excel_header(excel_list[0]))
  #生成csv数据内容
  for excel_name in excel_list:
    for row_value in read_excel(excel_name):
      xlsx_to_csv(csv_file_name,row_value)
  print('Excel文件转csv文件结束 ')

https://www.cnblogs.com/qican/p/11122206.html

MPTCP mptcp_v6_mapped bug

https://github.com/multipath-tcp/mptcp/issues/501

git log -p -1 6baa3e5d7fd3e8efa6e9ced5f1ee22547c0889d1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
commit 6baa3e5d7fd3e8efa6e9ced5f1ee22547c0889d1
Author: Matthieu Baerts <matthieu.baerts@tessares.net>
Date:   Thu Dec 29 15:35:24 2022 +0100

    mptcp: set icsk_af_ops to mptcp_v6 one if mptcp
    
    abcdxyzk recently opened a very detailed bug report on Github where it
    is noticed that surprisingly, AF_INET{4,6} operations were set to MPTCP
    specific functions if the attached connection was *not* an MPTCP one.
    
    This is a typo of course.
    
    As explained by Christoph, there was no consequences: mptcp_v6_mapped
    only changes conn_request to mptcp_conn_request(): that's only important
    with listening sockets, not used here then.
    
    Anyway, it is still better to properly fix that just in case other
    functions from mptcp_v6_mapped are modified later.
    
    Closes: https://github.com/multipath-tcp/mptcp/issues/501
    Fixes: db745ef1568d ("mptcp: Only access the sysctl once to detect mptcp-enabled")
    Suggested-by: Christoph Paasch <cpaasch@apple.com>
    Reviewed-by: Timothée Boucher-Lambert <timothee.boucher-lambert@tessares.net>
    Acked-by: Christoph Paasch <cpaasch@apple.com>
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    (cherry picked from commit edd63c2dab7ecb48b1613d112d2779c222d2bec1)
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    (cherry picked from commit 772b4de2997d6bcda92ca37afa9f69ed853c6b7a)
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>

diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 2e262aa2674a..bbdd53191c35 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1161,7 +1161,7 @@ struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
      /* We must check on the request-socket because the listener
       * socket's flag may have been changed halfway through.
       */
-     if (!inet_rsk(req)->saw_mpc)
+     if (inet_rsk(req)->saw_mpc)
          inet_csk(newsk)->icsk_af_ops = &mptcp_v6_mapped;
      else
 #endif

PHPExcel, html 如何设置上标、下标

https://zhidao.baidu.com/question/223583432.html

PHP

PHPExcel 上标、下标设置属性:setSuperScript()、setSubScript()

1
2
3
4
5
6
$richText = new \PhpOffice\PhpSpreadsheet\RichText\RichText();
$richText->createText('mm');
$nextText = $richText->createTextRun('2');
$nextText->getFont()->setSuperScript(true);
$nextText->getFont()->setBold(true);
$sheet->setCellValue("{$H[5]}{$l}", $richText);

HTML

1
啊啊啊啊啊<sup>上标</sup>啊啊啊啊啊<sub>下标</sub>啊啊啊啊啊啊

啊啊啊啊啊上标啊啊啊啊啊下标啊啊啊啊啊啊