Python论坛  - 讨论区

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

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

charles huang hyy at fjii.com
Fri Sep 24 10:52:25 HKT 2004

topcat,您好!
   呵呵,我试过了,知道print的是这样,只是感到奇怪,直接敲a和print a会不一样,估计是print的时候把斜杆给省了一个,不过,如果作为参数传递,不知道会不会有问题。
	

======= 2004-09-24 10:23:13 您在来信中写道:=======

>晕啊,你自己print出来看看是 \\ 还是 \
>
>
>On Fri, 24 Sep 2004 09:59:04 +0800, charles huang <hyy at fjii.com> wrote:
>> 诸位大侠!
>> 
>>         诸位大侠,还是不行啊!好像会出错的
>> >>> s=["a","b","c"]
>> >>> r'\'.join(s)
>> SyntaxError: EOL while scanning single-quoted string
>> >>>
>> 
>> 还有,俺组成的字符串一定要是单斜杆,并在字符前面,不能是双斜杆。像这样:"\a\b\c",不是"\\a\\b\\c"或者"a\\b\\c\\"之类的。
>> 
>> 
>> ======= 2004-09-24 09:23:25 您在来信中写道:=======
>> 
>> >On 2004-09-24 09:11:1095988293 +0800, Xie Yanbo wrote:
>> >> On 2004-09-24 09:04:1095987860 +0800, charles huang wrote:
>> >> > python-chinese,您好!
>> >> >      诸位大侠,如何把一个几个字符用"\"连起来?
>> >> >    比如:有 "abc" "def" "hig" 三个字符串,如何连成 "\abc\def\hig"
>> >> >    很难办啊!
>> >>
>> >> r'\'.join('abc', 'def', 'hig')
>> >
>> >不好意思,忘了 join 的参数应该是一个列表了,应该是这样的:
>> >
>> >  r'\'.join(['abc', 'def', 'hig'])
>> >
>> >--
>> >《淮上喜会梁川故人》
>> >作者:韦应物
>> >江汉曾为客,相逢每醉还。
>> >浮云一别后,流水十年间。
>> >欢笑情如旧,萧疏鬓已斑。
>> >何因北归去,淮上对秋山。
>> >
>> >_______________________________________________
>> >python-chinese list
>> >python-chinese at lists.python.cn
>> >http://python.cn/mailman/listinfo/python-chinese
>> >
>> 
>> = = = = = = = = = = = = = = = = = = = =
>> 
>>>> 礼!
>> 
>> charles huang
>> hyy at fjii.com
>> 
>> 
>> 
>> _______________________________________________
>> 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日 星期五 11:09

limodou limodou at gmail.com
Fri Sep 24 11:09:49 HKT 2004

头晕。:)


On Fri, 24 Sep 2004 10:52:25 +0800, charles huang <hyy at fjii.com> wrote:
> 
> 
> topcat,您好!
>   呵呵,我试过了,知道print的是这样,只是感到奇怪,直接敲a和print a会不一样,估计是print的时候把斜杆给省了一个,不过,如果作为参数传递,不知道会不会有问题。
> 
> ======= 2004-09-24 10:23:13 您在来信中写道:=======
> 
> >晕啊,你自己print出来看看是 \\ 还是 \
> >
> >
> >On Fri, 24 Sep 2004 09:59:04 +0800, charles huang <hyy at fjii.com> wrote:
> >> 诸位大侠!
> >>
> >>         诸位大侠,还是不行啊!好像会出错的
> >> >>> s=["a","b","c"]
> >> >>> r'\'.join(s)
> >> SyntaxError: EOL while scanning single-quoted string
> >> >>>
> >>
> >> 还有,俺组成的字符串一定要是单斜杆,并在字符前面,不能是双斜杆。像这样:"\a\b\c",不是"\\a\\b\\c"或者"a\\b\\c\\"之类的。
> >>
> >>
> >> ======= 2004-09-24 09:23:25 您在来信中写道:=======
> >>
> >> >On 2004-09-24 09:11:1095988293 +0800, Xie Yanbo wrote:
> >> >> On 2004-09-24 09:04:1095987860 +0800, charles huang wrote:
> >> >> > python-chinese,您好!
> >> >> >      诸位大侠,如何把一个几个字符用"\"连起来?
> >> >> >    比如:有 "abc" "def" "hig" 三个字符串,如何连成 "\abc\def\hig"
> >> >> >    很难办啊!
> >> >>
> >> >> r'\'.join('abc', 'def', 'hig')
> >> >
> >> >不好意思,忘了 join 的参数应该是一个列表了,应该是这样的:
> >> >
> >> >  r'\'.join(['abc', 'def', 'hig'])
> >> >
> >> >--
> >> >《淮上喜会梁川故人》
> >> >作者:韦应物
> >> >江汉曾为客,相逢每醉还。
> >> >浮云一别后,流水十年间。
> >> >欢笑情如旧,萧疏鬓已斑。
> >> >何因北归去,淮上对秋山。
> >> >
> >> >_______________________________________________
> >> >python-chinese list
> >> >python-chinese at lists.python.cn
> >> >http://python.cn/mailman/listinfo/python-chinese
> >> >
> >>
> >> = = = = = = = = = = = = = = = = = = = =
> >>
> >> 致
> >> 礼!
> >>
> >> charles huang
> >> hyy at fjii.com
> >>
> >>
> >>
> >> _______________________________________________
> >> 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
> 
> 
> 



-- 
I like python!


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

2004年09月24日 星期五 11:18

topcat jimingxin at gmail.com
Fri Sep 24 11:18:36 HKT 2004

不是把斜杆省了一个,在Python里,\是有特殊意义的,它后面跟上其他的字符表示一个字符,比如 \n 表示回车,\t表示TAB、\0x12
表示ASCII码为0x12的字符,等等,所以在Python里,要表示\字符,必须写成
"\\",但实际上,"\\"表示的就是一个字符\,你在解释器里敲a,所看到的双斜杠,是以Python的方法表示的,而用print打印出来的,就是实际的字符,如果你写到文件里,也会只看到一个斜杠,而如果你在文件里写一个斜杠然后在python里读取并在解释器中直接显示,也是"\\"。

不知道这样说你理解了没有,事实上上面已经有很多人说过这个问题了,如果还不明白的话,建议找本Python的教程先看一看。


On Fri, 24 Sep 2004 10:52:25 +0800, charles huang <hyy at fjii.com> wrote:
> 
> 
> topcat,您好!
>    呵呵,我试过了,知道print的是这样,只是感到奇怪,直接敲a和print a会不一样,估计是print的时候把斜杆给省了一个,不过,如果作为参数传递,不知道会不会有问题。
> 
> ======= 2004-09-24 10:23:13 您在来信中写道:=======
> 
> >晕啊,你自己print出来看看是 \\ 还是 \
> >
> >
> >On Fri, 24 Sep 2004 09:59:04 +0800, charles huang <hyy at fjii.com> wrote:
> >> 诸位大侠!
> >>
> >>         诸位大侠,还是不行啊!好像会出错的
> >> >>> s=["a","b","c"]
> >> >>> r'\'.join(s)
> >> SyntaxError: EOL while scanning single-quoted string
> >> >>>
> >>
> >> 还有,俺组成的字符串一定要是单斜杆,并在字符前面,不能是双斜杆。像这样:"\a\b\c",不是"\\a\\b\\c"或者"a\\b\\c\\"之类的。
> >>
> >>
> >> ======= 2004-09-24 09:23:25 您在来信中写道:=======
> >>
> >> >On 2004-09-24 09:11:1095988293 +0800, Xie Yanbo wrote:
> >> >> On 2004-09-24 09:04:1095987860 +0800, charles huang wrote:
> >> >> > python-chinese,您好!
> >> >> >      诸位大侠,如何把一个几个字符用"\"连起来?
> >> >> >    比如:有 "abc" "def" "hig" 三个字符串,如何连成 "\abc\def\hig"
> >> >> >    很难办啊!
> >> >>
> >> >> r'\'.join('abc', 'def', 'hig')
> >> >
> >> >不好意思,忘了 join 的参数应该是一个列表了,应该是这样的:
> >> >
> >> >  r'\'.join(['abc', 'def', 'hig'])
> >> >
> >> >--
> >> >《淮上喜会梁川故人》
> >> >作者:韦应物
> >> >江汉曾为客,相逢每醉还。
> >> >浮云一别后,流水十年间。
> >> >欢笑情如旧,萧疏鬓已斑。
> >> >何因北归去,淮上对秋山。
> >> >
> >> >_______________________________________________
> >> >python-chinese list
> >> >python-chinese at lists.python.cn
> >> >http://python.cn/mailman/listinfo/python-chinese
> >> >
> >>
> >> = = = = = = = = = = = = = = = = = = = =
> >>
> >> 致
> >> 礼!
> >>
> >> charles huang
> >> hyy at fjii.com
> >>
> >>
> >>
> >> _______________________________________________
> >> 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号