VBA 查找值所在的列号

Function FindColOfValue(ws As Worksheet, val As Variant, rowNum As Long, startCol As Long)
    Dim i As Long
    With ws
    For i = startCol To .Range(.Cells(startCol, rowNum), .Cells(startCol, rowNum)).CurrentRegion.Columns.Count()
        If .Cells(rowNum, i).Value = val Then
            FindColOfValue = i
            Exit Function
        End If
    Next
    End With
    
    FindColOfValue = -1
End Function

VBA 查找值所在的行号

Function FindRowOfValue(ws As Worksheet, val As Variant, colNum As Long, startRow As Long)
    Dim r As Long
    With ws
    For r = startRow To .Range(.Cells(startRow, colNum), .Cells(startRow, colNum)).CurrentRegion.Rows.Count()
        If .Cells(r, colNum).Value = val Then
            FindRowOfValue = r
            Exit Function
        End If
    Next
    End With
End Function

Python 字典排序

Sort a dictionary by value
依据字典的值进行排序

newDict = {k: v for k, v in sorted(x.items(), key=lambda item: item[1])}
import operator


# 示例字典
d = {'a': 3, 'e': 4, 'b': 2, 'c': 5, 'd': 1}


# 按 key 排序
def dict_sort_by_key(d: dict):
    sorted_d = sorted(d.items(), key=operator.itemgetter(0))
    return dict(sorted_d)

# 按 value 排序
def dict_sort_by_val(d: dict):
    # sorted_dic = dict(sorted(d.items(), key=operator.itemgetter(1)))
	
	sorted_keys=sorted(dict1, key=dict1.get)
	for k in sorted_keys:
		sorted_dic[k]=d[k]
	
    return sorted_dic


print(dict_sort_by_key(d))
# {'a': 3, 'b': 2, 'c': 5, 'd': 1, 'e': 4}

print(dict_sort_by_val(d))
# {'d': 1, 'b': 2, 'a': 3, 'e': 4, 'c': 5}

Python 计算 MD5 散列值

def get_md5_string(content)->str:
    """
    - content: bytes or string
    """
    m = hashlib.md5()
    if type(content) == bytes:
        m.update(content)
    elif type(content) == str:
        m.update(content.encode())
    else:
        return None
    return m.hexdigest()

AWS 在本地配置AWS资源访问授权

如果本地安装了 AWS CLI 可以直接使用 aws 命令进行配置:
aws configure

或者,可以手动创建证书文件,文件默认位置是 ~/.aws/credentials

文件内容:

[default]
aws_access_key_id=YOUR_ACCESS_KEY
aws_secret_access_key=YOUR_SECRET_KEY

如果要设置默认地区(Regoin),示例: