您的位置:首页 > 编程语言 > Python开发

Python学习笔记之20140406

2014-04-07 00:24 375 查看
# Time : 2014-4-6 23:39 Python学习笔记
1.Python输出中文
#!/usr/bin/python
#coding:utf-8
2.Python %s %r的区别
The %s specifier converts the object using str(), and %r converts it using repr().

For some objects such as integers, they yield the same result, but repr() is special in that (for types where this is possible) it conventionally returns a result that is valid Python syntax, which could be used to unambiguously recreate the object
it represents.

Here's an example, using a date:

>>> d = datetime.date.today()
>>> str(d)
'2011-05-14'
>>> repr(d)
'datetime.date(2011, 5, 14)'

Types for which repr() doesn't produce Python syntax include those that point to external resources such as a file, which you can't guarantee to recreate in a different context.
3.print "." * 10 以及 + 的应用
4. formatter = "%r %r %r %r"
5. \n \t 以及 """ 以及转义字符(diffcult-to-type)\的使用
6. 输入函数 raw_input()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: