Python基础 (3) - String, Long String, Raw String
2008-09-15 13:10
441 查看
我喜欢用例子说明,语文不是很好-_-,直接看code吧
长String,可以用 '''.......'''来定义,或者"""......"""
当在想在输入时换行,而显示时不换行的话,就在一行末加上"/"(没有引号)
看code吧
Raw string
还是看code先
其中print r'...'就是print 原始的string.
长String,可以用 '''.......'''来定义,或者"""......"""
>>> print '''This is really a long Sting, I want to play but I have no time python is good, show a "hello world" end''' This is really a long Sting, I want to play but I have no time python is good, show a "hello world" end
当在想在输入时换行,而显示时不换行的话,就在一行末加上"/"(没有引号)
看code吧
>>>print "hello, / world" hello, world
>>> print / "hello world" hello world
>>> 1+2+3/ +4+5 15
Raw string
还是看code先
>>> print 'Hello, /nworld' Hello, world >>> print "hello, /nworld" hello, world >>> t = "hello, /nworld" >>> t 'hello, /nworld' >>> print t hello, world >>> print r'"hello /nworld"' "hello /nworld"
其中print r'...'就是print 原始的string.
相关文章推荐
- Python基础-int和string互相转换
- 基础 python(四)string与list的相互转换
- python基础: String类型
- python基础31[docstring]
- python基础===string模块常量
- python之string模块 分类: python基础学习 python Module 2013-08-27 13:58 241人阅读 评论(0) 收藏
- python基础 1: string
- python基础学习——列表(list), 元祖(tuple), 字典(dict), 字符串(string), 集合(set) 介绍及相互转换
- python基础数据结构——列表(list), 元祖(tuple), 字典(dict), 字符串(string), 集合(set) 介绍及相互转换
- 基础 python(三)关于string的几个tips
- Python3 Tkinter基础 Button Label Frame 单击按钮,Label中显示的文字更换 StringVar textvariable
- Python基础-String字符串
- Python基础:数据类型-字符串:string
- Python3基础类型String
- Python 基础 —— docstring
- python string模块 分类: python基础学习 python Module 2013-08-16 17:50 294人阅读 评论(0) 收藏
- python基础31[docstring]
- Python基础-StringIO和BytesIO
- 【Python】基础学习——列表(list),元祖(tuple),字典(dict),字符串(string),集合(set)
- Python3 与 C# 基础语法对比(String专栏)