我正在尝试使用一些HTML来处理我的python代码.我有一个我的CSS代码.
#footerBar {
height: 40px;
background: red;
position: fixed;
bottom: 0;
width: 100%;
z-index: -1;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试访问该页面时,出现以下错误.
File "projv2.py", line 151, in welcome
</form>""" %(retrievedFullName, retrievedUserName,)
ValueError: unsupported format character ';' (0x3b) at index 1118
Run Code Online (Sandbox Code Playgroud)
我认为它搞乱了,%因为我在HTML中的其他地方使用它.
任何帮助将不胜感激.
Kim*_*ais 19
如果要使用%格式化运算符,则需要转义%字符.
所以你的CSS应该是:
#footerBar {
height: 40px;
background: red;
position: fixed;
bottom: 0;
width: 100%%;
z-index: -1;
}
Run Code Online (Sandbox Code Playgroud)
代替.
最好使用字符串的.format()方法,因为它是更好的方法.有关基本原理,请参阅PEP 3101.
而不是
...""" % (retrievedFullName, retrievedUserName,)
Run Code Online (Sandbox Code Playgroud)
做
...""".format(retrievedFullName, retrievedUserName)
Run Code Online (Sandbox Code Playgroud)
并将%s字符串中的's 更改为{0}和{1}.当然,{}在这种情况下你也需要逃避.