[Ubuntu-zh] Py新手求问
张淳
zhangchun在xiguaner.com
星期四 一月 20 08:27:55 UTC 2011
%c是“单字符”格式化符号
print ("%c" %
b)会把12转换为ASCII字符,也就是ASCII中数值为12的字符,你可以去查看ASCII表,12对应的是不可见字符,所以显示方块。
print ("Welcome \a to \r Python!")中
\a和\r都是转义字符。就像\n代表换行,而\a是无意义的,单独的\r是回车符,也就是将光标移到行开头,是不可见的,除非和\n组合使用为Windows风格换行符。
在 2011年1月20日 下午4:12,Qi Wang <qiwang.zju在gmail.com>写道:
> >>> b=12
> >>> print ("%c" % b)
> □
> >>> b=1
> >>> print ("%c" % b)
> □
>
> 为什么会出现方框呢?
>
> print ("Welcome \a to \r Python!")
> 得到
> Welcome □ to Python!
> 中的“\a”为什么得到的也是方框 而\r 没有任何效果。
>
> Py新手……
> 真诚求教……
>
> ------------------------------------------------------------
> Biological science '11, Zhejiang University
> College of Life Sciences
>
> Room 205,Qingxi 1st, Zijingang Campus, Zhejiang University, Hangzhou,
> 310058, PR China
> Tel:+86-13732288062
> -------------- 下一部分 --------------
> 一个HTML附件被移除...
> URL: <
> https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20110120/f153f895/attachment.html
> >
> --
> ubuntu-zh mailing list
> ubuntu-zh在lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh
>
-------------- 下一部分 --------------
一个HTML附件被移除...
URL: <https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20110120/1af608ee/attachment.html>
关于邮件列表 ubuntu-zh 的更多信息