Python学习笔记之20140406

来源:互联网 发布:日本捕鲸 知乎 编辑:程序博客网 时间:2024/06/14 10:47
# 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()
0 0
原创粉丝点击