Python学习笔记之20140406

# 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()
发布了40 篇原创文章 · 获赞 3 · 访问量 6万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章