復制代碼 代碼如下:
a = 'aadsdf\"'
print(string.format("%q",a))
%d
十進制整數
%o
八進制整數
%x
十六進制整數,大寫的話為 %X
%f
浮點型 格式 [-]nnnn.nnnn
%e
科學表示法 格式 [-]n.nnnn e [+|-]nnn, 大寫的話為 %E
%g
floating-point as %e if exp. < -4 or >= precision, else as %f ; uppercase if %G .
%c
character having the (system-dependent) code passed as integer
%s
沒有\0的字符串
%q
雙引號間的string, with all special characters escaped
%%
' % ' 字符
%a 字母
%c控制字符
%d多個數字
%l 小寫字母
%p標點符號
%s空白字符
%x十六進制
%z內部表示為0的字符