Python: urllib.parse.quote_plus 并编辑字符串

Python: urllib.parse.quote_plus and edit string

我需要向 urllib.parse.quote_plus 命令添加通配符,但我不清楚如何添加。

当我在我的烧瓶服务器上执行以下命令时,出现以下错误:

ValueError: unsupported format character 'D' (0x44) at index 8

如何在此处添加通配符以接受对象?

user_email = 'my_email@xd.com'
params = urllib.parse.quote_plus("Driver={ODBC Driver 17 for SQL Server};Server=tcp:dbhere.database.windows.net,1433;Database=dbhere;Uid=%s;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=15;Authentication=ActiveDirectoryIntegrated")
params.replace('%s;', user_email)
# result
'Driver%3D%7BODBC+Driver+17+for+SQL+Server%7D%3BServer%3Dtcp%3Adbhere.database.windows.net%2C1433%3BDatabase%3Ddbhere%3BUid%3D%25s%3BEncrypt%3Dyes%3BTrustServerCertificate%3Dno%3BConnection+Timeout%3D15%3BAuthentication%3DActiveDirectoryIntegrated'

我觉得你应该先做替换

user_email = 'my_email@xd.com'
params = urllib.parse.quote_plus("stuff;Uid=%s;stuff" % user_email)

params = urllib.parse.quote_plus(f"stuff;Uid={user_email};stuff")