主题
常用API
拷贝字符串到剪贴板
python
import pyperclip
pyperclip.copy(imgLink)
pip install pyperclip
获取当前用户的下载目录
python
import ctypes.wintypes
def getDocPath(pathID=5):
'''path=5: My Documents'''
buf= ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
ctypes.windll.shell32.SHGetFolderPathW(None, pathID, None, 0, buf)
return buf.value
downloadPath = os.path.join(os.path.dirname(getDocPath(0)),"Downloads")
print(downloadPath)
C:\Users\wangx\Downloads
获取主机名
python
os.popen('hostname').read().replace("\n","")
DESKTOP-7O54MHN