日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python网址太长_【原创】分享一个自己用python写的长网址转短网址工具,给需要的你...

發布時間:2025/3/11 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python网址太长_【原创】分享一个自己用python写的长网址转短网址工具,给需要的你... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

[Python] 純文本查看 復制代碼import requests

import json

from tkinter import *

class Get_url_short():

def __init__(self):

self.source = 2540340328

self.url = 'https://api.t.sina.com.cn/short_url/shorten.json?'

def get_short(self):

try:

url_long = self.tk_url_long.get()

url = self.url + 'source=' + str(self.source) + '&url_long=' + str(url_long)

html = requests.get(url)

html = html.text

html = json.loads(html)

self.url_short = html[0]['url_short']

Label(text='Short URL:').grid(row=1, column=0)

Label(text=self.url_short).grid(row=1, column=1)

Button(self.short, text="Copy", width=10, command=self.short_copy).grid(row=1, column=2, sticky=W, padx=10, pady=5)

except:

Label(text='請輸入帶http或https的長鏈接').grid(row=2, column=1)

def short_copy(self):

try:

self.short.clipboard_clear() # 清除剪貼板內容

self.short.clipboard_append(self.url_short) # 向剪貼板追加內容

Label(text='URL copy succeeded',font=', 10').grid(row=2, column=1)

except:

Label(text='URL copy failed',font=', 10').grid(row=2, column=1)

def short_begin(self):

self.short = Tk()

self.short.title('Short URL')

Label(text='Long URL:').grid(row=0, column=0)

self.tk_url_long = Entry(self.short)

self.tk_url_long.grid(row=0, column=1)

Button(self.short, text="轉化", width=10, command=self.get_short).grid(row=0, column=2, sticky=W, padx=10, pady=5)

mainloop()

if __name__ == '__main__':

short = Get_url_short()

short.short_begin()

總結

以上是生活随笔為你收集整理的python网址太长_【原创】分享一个自己用python写的长网址转短网址工具,给需要的你...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。