程序员老王 发布的文章
python打印文件名,行号
import sys
import datetime
import os
def print_with_lineno(message):
frame = sys._getframe(1) # 获取调用者的帧
lineno = frame.f_lineno # 行号
filename = os.path.basename(frame.f_code.co_filename) # 提取文件名
current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 格式化时间
print(f"{current_time} - {filename} - Line {lineno}: {message}")
# 示例
print_with_lineno("This is a test message")
print_with_lineno("Another message")
adb常用命令
#列出设备
adb devices
# 安装软件
adb install **.apk
python获取用户主目录
import os
os.path.expanduser("~")
Let's Encrypt 免费 https证书
安装certbot
sudo apt install certbot python3-certbot-nginx
sudo certbot