Python论坛  - 讨论区

标题:Re: [python-chinese] Re: [python-ch inese] 一个字符 串的问题

2004年09月24日 星期五 10:15

charles huang hyy at fjii.com
Fri Sep 24 10:15:53 HKT 2004

Levin Du,您好!

	奇怪啊!怎么直接敲a和print a会不一样,双斜杆变成了单斜杆了?

======= 2004-09-24 09:45:29 您在来信中写道:=======

>呵,格式化输出而已
>
>>>> a="\\"+"abc"+"\\"+"def"+ "\\" + "ghi"
>>>> a
>'\\abc\\def\\ghi'
>>>> print a
>\abc\def\ghi
>
>
>On Fri, 24 Sep 2004 09:19:18 +0800, Eric Luo <eric.python at gmail.com> wrote:
>> >>> s = ["abc", "def", "hit"]
>> >>> print '\\'.join(s)
>> abc\def\hit
>> 不知道你要的是不是这个?
>> 
>> 
>> On Fri, 24 Sep 2004 09:04:20 +0800, charles huang <hyy at fjii.com> wrote:
>> > python-chinese,您好!
>> >      诸位大侠,如何把一个几个字符用"\"连起来?
>> >         比如:有 "abc" "def" "hig" 三个字符串,如何连成 "\abc\def\hig"
>> >         很难办啊!
>> >
>> > 致
>> > 礼!
>> >
>> >
>> > charles huang
>> >
>> >
>> >
>> > _______________________________________________
>> > python-chinese list
>> > python-chinese at lists.python.cn
>> > http://python.cn/mailman/listinfo/python-chinese
>> >
>> >
>> >
>> 
>> 
>> _______________________________________________
>> python-chinese list
>> python-chinese at lists.python.cn
>> http://python.cn/mailman/listinfo/python-chinese
>>
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        charles huang
        hyy at fjii.com
			   TEL: 0591-3333169-212
          2004-09-24


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年09月24日 星期五 10:51

Levin Du Levin.Du at gmail.com
Fri Sep 24 10:51:46 HKT 2004

哈,看看这个:
>>> a="\\a"
>>> print a.__str__()
\a
>>> print a.__repr__()
'\\a'

直接敲a,会调用print a.__repr__()

两个函数 __str__ 和 __repr__ 的区别请参见文档:)

On Fri, 24 Sep 2004 10:15:53 +0800, charles huang <hyy at fjii.com> wrote:
> Levin Du,您好!
> 
>         奇怪啊!怎么直接敲a和print a会不一样,双斜杆变成了单斜杆了?
> 
> ======= 2004-09-24 09:45:29 您在来信中写道:=======
> 
> 
> 
> >呵,格式化输出而已
> >
> >>>> a="\\"+"abc"+"\\"+"def"+ "\\" + "ghi"
> >>>> a
> >'\\abc\\def\\ghi'
> >>>> print a
> >\abc\def\ghi
> >
> >
> >On Fri, 24 Sep 2004 09:19:18 +0800, Eric Luo <eric.python at gmail.com> wrote:
> >> >>> s = ["abc", "def", "hit"]
> >> >>> print '\\'.join(s)
> >> abc\def\hit
> >> 不知道你要的是不是这个?
> >>
> >>
> >> On Fri, 24 Sep 2004 09:04:20 +0800, charles huang <hyy at fjii.com> wrote:
> >> > python-chinese,您好!
> >> >      诸位大侠,如何把一个几个字符用"\"连起来?
> >> >         比如:有 "abc" "def" "hig" 三个字符串,如何连成 "\abc\def\hig"
> >> >         很难办啊!
> >> >
> >> > 致
> >> > 礼!
> >> >
> >> >
> >> > charles huang
> >> >
> >> >
> >> >
> >> > _______________________________________________
> >> > python-chinese list
> >> > python-chinese at lists.python.cn
> >> > http://python.cn/mailman/listinfo/python-chinese
> >> >
> >> >
> >> >
> >>
> >>
> >> _______________________________________________
> >> python-chinese list
> >> python-chinese at lists.python.cn
> >> http://python.cn/mailman/listinfo/python-chinese
> >>
> >_______________________________________________
> >python-chinese list
> >python-chinese at lists.python.cn
> >http://python.cn/mailman/listinfo/python-chinese
> 
> = = = = = = = = = = = = = = = = = = = =
> 
>> 礼!
> 
> 
> charles huang
> hyy at fjii.com
>                            TEL: 0591-3333169-212
> 2004-09-24
> 
> 
> 
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 
> 
>


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号