ValueError:索引40处不支持的格式字符“{”(0x7b)Python&CURL

2022-01-19 01:16:26 发布

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

我正在尝试创建一个程序,可以分析终端中网站的速度。我使用curl模块在Linux shell中处理该命令。但我得到了以下错误

ValueError: unsupported format character '{' (0x7b) at index 40

import subprocess

def webSpeed():
    website = raw_input("Enter name of the website:  ")
    print(website)
    cmd = "curl -s -w 'Website Response Time for :%{url_effective}\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nAppCon Time:\t\t%{time_appconnect}\nRedirect Time:\t\t%{time_redirect}\nPre-transfer Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null https://%s" %(webiste)
    print(cmd)
    temp = subprocess.call(cmd, shell="TRUE")
    print(temp)

如果python使用大括号,如何在python中添加curl命令