2024-09-26 18:00:55 发布
网友
当字符串类似于:
s = 'test%s1' s % 'TEST'
但是,当%本身出现在字符串中时,我得到了这个错误。 例如:
%
s = 'test%s12%34' s % 'TEST' >>ValueError: incomplete format
如何处理这个案子??你知道吗
加倍%:
s = 'test%s12%%34'
在输出时,它将再次折叠为一个百分比符号:
>>> s = 'test%s12%%34' >>> s % 'TEST' 'testTEST12%34'
在String Formatting Operations documentation中,记录了各种转换字符:
'%' No argument is converted, results in a '%' character in the result.
'%'
其中第二个%是转换字符。你知道吗
加倍
%
:在输出时,它将再次折叠为一个百分比符号:
在String Formatting Operations documentation中,记录了各种转换字符:
其中第二个
%
是转换字符。你知道吗相关问题 更多 >
编程相关推荐