-1

这是python代码:

import pyshorteners as p
    
link=input("Enter the link: ")
shortner=p.tinyurl.short(link)
x=shortner.tinyurl.short(link)

print(x)

这是错误: module 'pyshorteners' has no attribute 'tinyurl'

4

2 回答 2

1

代替

shortner=p.tinyurl.short(link)

shortner=p.Shortener()

取自此处的示例:https ://pyshorteners.readthedocs.io/en/latest/

于 2021-12-25T08:34:49.827 回答
1

那是因为pyshorteners没有属性tinyurl尝试使用文档中的示例(https://pyshorteners.readthedocs.io/en/latest/apis.html#tinyurl-com

import pyshorteners
s = pyshorteners.Shortener()
s.tinyurl.short('http://www.google.com')
于 2021-12-25T08:37:26.653 回答