打开 应用
open.py
import os
os.system(r"C:\Users\bigbrolee\AppData\Local\Google\Chrome\Application\chrome.exe www.baidu.com")
微信收藏.py
import urllib.parse
import win32clipboard
import win32con
import os
def getClipboardText():
win32clipboard.OpenClipboard()
result = win32clipboard.GetClipboardData(win32con.CF_TEXT)
win32clipboard.CloseClipboard()
return result
if __name__ == "__main__":
#input('复制网址,回车')
url=getClipboardText()
url=url.decode('utf-8') #transform bytes into str
url = str(url)
chrome = r"C:\Users\bigbrolee\AppData\Local\Google\Chrome\Application\chrome.exe"
prefix = r'http://sc.qq.com/'
if url.startswith(prefix):
url = url[17:] #strip 'http://sc.qq.com/'
url= urllib.parse.unquote(url)
url_list_str = ''.join([u if u !='&' else '^&' for u in list(url) ]) #cmd 命令行 对&是保留字,需要^来转义
#另外,包含if for else的列表生成式
#另另外,str_convert = ''.join(list) ,将list转回str
os.system("{0} {1}".format(chrome,url_list_str))
else:
os.system("{0} {1}".format(chrome,url))
# trans_url= urllib.parse.unquote(url)
# with open(r'C:\Users\bigbrolee\Desktop\微信收藏地址.txt',mode='a',encoding='utf-8') as f:
# f.write(trans_url)
# f.write('\n')
网友评论