我试图让用户不需要输入http://. 如何使用Python预填充输入?

2024-09-24 08:37:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我想有一个已经为用户预先填充的输入,这样他们就不需要输入http://. 我试过"prefilled=http://",但没有成功

url = input("Enter a URL address starting with http:// ")

Tags: 用户httpurlinputaddresswithenterstarting
2条回答

input函数添加提示不会将其添加到字符串中。保存后必须添加

url = input("Enter a URL address starting with http:// ")
if not url.startswith("http://"):
    url = "http://" + url

如何进行后处理来添加http(s)://如果它丢失了呢

相关问题 更多 >