python笔记-字符串
2016-01-12 15:16
525 查看
>>> myString = 'hello world !' >>> print myString # print语句会调用str()函数 hello world ! >>> myString # 直接使用变量名,输出的字符串是用单引号括起来的。其实,交互式解释器调用的是repr()函数 'hello world !' >>> _ # _在解释器中有特殊含义,表示最后一个表达式的值 'hello world !'
">>"重定向输出:
>>> logfile=open('/tmp/mylog.txt','a') >>> print >> logfile,'just a test !' >>> logfile.close() >>> # more /tmp/mylog.txt just a test !
相关文章推荐
- python数字图像处理(8):对比度与亮度调整
- Python的 startswith 和endswith
- python 2.5.5 迭代器
- Python学习手册 - 09
- python文件操作
- python的 __name__和__doc__属性
- 自学Python二 Python中的屠龙刀(续)
- VirtualEnv安装
- python数字图像处理(7):图像的形变与缩放
- 搭建自己的pypi服务器
- windows 下安装python 的pygraphviz包方法
- Python文件配置configParser使用
- python request属性及方法说明
- Python -- list 类
- python模拟登录微博网站利用urllib2 和 cookie
- 深入理解Python的字符编码utf-8 & unicode
- set() in python
- python中的接口
- 深入理解python之self
- python 单行注释/多行注释/代码间注释/特殊注释/"""doc String