Python论坛  - 讨论区

标题:[python-chinese] 新手,请教一个字符串处理的问题

2006年08月02日 星期三 12:40

Huang Cong mail.huangcong at gmail.com
Wed Aug 2 12:40:22 HKT 2006

target = target_dir + r'\' + time.strftime('%Y') + '.rar'
请问上面这句话什么地方错了?
改成下面这样就ok了~想不太明白~
target = target_dir + '\\' + time.strftime('%Y') + '.rar'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060802/a877b426/attachment.htm

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

2006年08月02日 星期三 12:48

limodou limodou at gmail.com
Wed Aug 2 12:48:25 HKT 2006

On 8/2/06, Huang Cong <mail.huangcong at gmail.com> wrote:
>
> target = target_dir + r'\' + time.strftime('%Y') + '.rar'
> 请问上面这句话什么地方错了?
> 改成下面这样就ok了~想不太明白~
> target = target_dir + '\\' + time.strftime('%Y') + '.rar'

你对r可能不太清楚。在r中\不再转义,但不能单用。后面必须要有一个字符。所以
r'\'是不行的。还是用'\\'吧。

-- 
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

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

2006年08月02日 星期三 12:54

Leo Jay python.leojay at gmail.com
Wed Aug 2 12:54:36 HKT 2006

On 8/2/06, Huang Cong <mail.huangcong at gmail.com> wrote:
>
>  target = target_dir + r'\' + time.strftime('%Y') + '.rar'
> 请问上面这句话什么地方错了?
> 改成下面这样就ok了~想不太明白~
> target = target_dir + '\\' + time.strftime('%Y') + '.rar'
>


细节见python manual 中language reference的2.4.1节

总结下来一句话:*a raw string cannot end in a single backslash*

-- 
Best Regards,
Leo Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060802/358cc6b1/attachment.html

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

2006年08月02日 星期三 13:31

Xiao Lei Wu xiaoleiw at cn.ibm.com
Wed Aug 2 13:31:54 HKT 2006

ÄãΪʲôҪ¼Ór£¿ÊÇΪÁËתÒåÂð£¿Ë­¸æËßÄãתÒåÓÃrµÄ£¿
Ò»°ãתÒ嶼ÓÃ\
ÕâÊdz£Ê¶

ÁíÍ⣬½øÐÐÎļþ²Ù×÷×îºÃ²»ÒªÖ±½ÓÓÃ/ºÍ\ʲôµÄ£¬×îºÃÓÃϵͳ³£Á¿£ºos.sep
os.sep»á¸ú¾ÝËùÔڵIJÙ×÷ϵͳ×Ô¶¯±ã³ÉÏàÓ¦µÄĿ¼·Ö¸î·û

Best Regards,

Zachary Wu (Îâ°~ÀÚ)
Software Engineer, Enterprise Content Management FVT, IBM China Software
Development Lab
Tel: +86 10 82782244-3235. Fax: 82782244-2886 Tie Line: 915-2244-3235
Internet: xiaoleiw at cn.ibm.com
Notes ID: Xiao Lei Wu/China/Contr/IBM at IBMCN
Address: 8/F, Block A, Power Creative Building, No.1, East Road, Shang Di,
Beijing 100085, P.R. China

python-chinese-bounces at lists.python.cn дÓÚ 2006-08-02 12:40:22:

> target = target_dir + r'\' + time.strftime('%Y') + '.rar'
> ÇëÎÊÉÏÃæÕâ¾ä»°Ê²Ã´µØ·½´íÁË£¿
> ¸Ä³ÉÏÂÃæÕâÑù¾ÍokÁË¡«Ï벻̫Ã÷°×¡«
> target = target_dir + '\\' + time.strftime('%Y') + '.rar'
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060802/9b2b9567/attachment.html

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

2006年08月02日 星期三 13:35

limodou limodou at gmail.com
Wed Aug 2 13:35:48 HKT 2006

On 8/2/06, Xiao Lei Wu <xiaoleiw at cn.ibm.com> wrote:
>
>
>
> 你为什么要加r?是为了转义吗?谁告诉你转义用r的?
>  一般转义都用\
>  这是常识

他加r是因为用r来修饰的字符串,对于\不用写两个了,为了简单。但要是只处理一个'\',还是用'\\'吧。
>
>  另外,进行文件操作最好不要直接用/和\什么的,最好用系统常量:os.sep
>  os.sep会跟据所在的操作系统自动便成相应的目录分割符
>
如果在python内部处理,可以全部使用'/',当然混合也无所谓。如果一定要按操作系统的格式来输出,可以使用os.path.normcase,它会自动根据操作系统来转换分隔符的。

-- 
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

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

2006年08月02日 星期三 13:41

lubiao lubiao.py at gmail.com
Wed Aug 2 13:41:12 HKT 2006

On 8/2/06, Xiao Lei Wu <xiaoleiw at cn.ibm.com> wrote:
>
>  你为什么要加r?是为了转义吗?谁告诉你转义用r的?
> 一般转义都用\
> 这是常识
>

会屁点东西也装,
不懂还瞎说。
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060802/bf3ac9d9/attachment.htm

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

2006年08月02日 星期三 13:45

IQDoctor huanghao.c at gmail.com
Wed Aug 2 13:45:26 HKT 2006

1M6ho6GjILrDusPLtbuwsrvQ0MO0oaMKv7TAtL3M0/2yu7ni0qq0083ezd7XpcbwoaOhowoK1Nog
MDYtOC0yo6xYaWFvIExlaSBXdTx4aWFvbGVpd0Bjbi5pYm0uY29tPiDQtLXAo7oKPgo+Cj4KPiDE
486qyrLDtNKqvNNyo7/Kx86qwcvXqtLlwvCjv8utuObL38Tj16rS5dPDcrXEo78KPiDSu7Dj16rS
5ba808NcCj4g1eLKx7OjyrYKPgo+IMHtzeKjrL340NDOxLz+stnX99fuusOyu9Kq1rG909PDL7r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uux.org/pipermail/zeuux-python]

2006年08月02日 星期三 13:47

Leo Jay python.leojay at gmail.com
Wed Aug 2 13:47:49 HKT 2006

On 8/2/06, Xiao Lei Wu <xiaoleiw at cn.ibm.com> wrote:
>
>  你为什么要加r?是为了转义吗?谁告诉你转义用r的?
> 一般转义都用\
> 这是常识
>
Errr, 基本上,他加r是为了不要让\转义,而不是要转义
你水平不错,但说话的语气很讨厌~~~


-- 
Best Regards,
Leo Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060802/8b17511c/attachment.htm

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

2006年08月02日 星期三 13:49

xxmplus xxmplus at gmail.com
Wed Aug 2 13:49:33 HKT 2006

你怎么什么都要骂

On 8/2/06, lubiao <lubiao.py at gmail.com> wrote:
>
>
>
> On 8/2/06, Xiao Lei Wu <xiaoleiw at cn.ibm.com> wrote:
> >
> >
> >
> >
> > 你为什么要加r?是为了转义吗?谁告诉你转义用r的?
> > 一般转义都用\
> > 这是常识
>
>
>
> 会屁点东西也装,
> 不懂还瞎说。
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request at lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>
>


-- 
Any complex technology which doesn't come with documentation must be the best
available.

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

2006年08月02日 星期三 13:59

Huang Cong mail.huangcong at gmail.com
Wed Aug 2 13:59:37 HKT 2006

多谢Leo Jay,我加r是为了保留'\'字符而不转义,看了python
manual以后明白了,不能用r保留一个单独的'\'字符,因为'\'会把后面的"'"转义掉(好像是这样,不对欢迎大家说)

在06-8-2,Leo Jay <python.leojay at gmail.com> 写道:
>
>  On 8/2/06, Xiao Lei Wu <xiaoleiw at cn.ibm.com> wrote:
> >
> >  你为什么要加r?是为了转义吗?谁告诉你转义用r的?
> > 一般转义都用\
> > 这是常识
> >
> Errr, 基本上,他加r是为了不要让\转义,而不是要转义
> 你水平不错,但说话的语气很讨厌~~~
>
>
> --
> Best Regards,
> Leo Jay
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060802/32e38251/attachment-0001.html

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

2006年08月02日 星期三 14:22

Leo Jay python.leojay at gmail.com
Wed Aug 2 14:22:56 HKT 2006

On 8/2/06, Huang Cong <mail.huangcong at gmail.com> wrote:
>
> 多谢Leo Jay,我加r是为了保留'\'字符而不转义,看了python
> manual以后明白了,不能用r保留一个单独的'\'字符,因为'\'会把后面的"'"转义掉(好像是这样,不对欢迎大家说)
>
>

嗯,基本正确,确切的说是不能在字符串的最后面保留一个'\'字符,
像r'abcd\'也是不可以的

-- 
Best Regards,
Leo Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060802/9f47e134/attachment.htm

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

2006年08月02日 星期三 14:30

and andromeda100 at 126.com
Wed Aug 2 14:30:09 HKT 2006

批评和抱怨等负面情绪,不要往外发,如果能经常检查和修正自己,你就是“圣人”!
人,就像一段程序,对外部信息要有足够的缓冲处理能力。千万不要动气,动气之类的,在程序里容易造成资源死锁,或者严重破坏固有的程序逻辑。
大家不要互相批评,包容包容!:)

-------------------------------------------------------------
subject:Re: [python-chinese] 新手,请教一个字符串处理的问题
Leo Jay

On 8/2/06, Xiao Lei Wu <xiaoleiw at cn.ibm.com> wrote:
>
>  你为什么要加r?是为了转义吗?谁告诉你转义用r的?
> 一般转义都用\
> 这是常识
>
Errr, 基本上,他加r是为了不要让\转义,而不是要转义
你水平不错,但说话的语气很讨厌~~~


-- 
Best Regards,
Leo Jay
_______________________________________________
python-chinese
Post: send python-chinese at lists.python.cn
Subscribe: send subscribe to python-chinese-request at lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese

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

2006年08月02日 星期三 14:45

Xiao Lei Wu xiaoleiw at cn.ibm.com
Wed Aug 2 14:45:53 HKT 2006

ÎÒ˵»°Ò»Ö±ÊÇÕâ¸öÓïÆø£¬Ã»Ê²Ã´ÌرðµÄÒâ˼£¬¸úˮƽû¹Øϵ
PS:ÎÒûʲôˮƽµÄ

Best Regards,

Zachary Wu (Îâ°~ÀÚ)
Software Engineer, Enterprise Content Management FVT, IBM China Software
Development Lab
Tel: +86 10 82782244-3235. Fax: 82782244-2886 Tie Line: 915-2244-3235
Internet: xiaoleiw at cn.ibm.com
Notes ID: Xiao Lei Wu/China/Contr/IBM at IBMCN
Address: 8/F, Block A, Power Creative Building, No.1, East Road, Shang Di,
Beijing 100085, P.R. China

python-chinese-bounces at lists.python.cn дÓÚ 2006-08-02 14:30:09:

> ÅúÆÀºÍ±§Ô¹µÈ¸ºÃæÇéÐ÷£¬²»ÒªÍùÍâ·¢£¬Èç¹ûÄܾ­³£¼ì²éºÍÐÞÕý×Ô¼º£¬Äã¾ÍÊÇ¡°Ê¥
ÈË¡±£¡
> ÈË£¬¾ÍÏñÒ»¶Î³ÌÐò£¬¶ÔÍⲿÐÅÏ¢ÒªÓÐ×ã¹»µÄ»º³å´¦ÀíÄÜÁ¦¡£Ç§Íò²»Òª¶¯Æø£¬¶¯
> ÆøÖ®ÀàµÄ£¬ÔÚ³ÌÐòÀïÈÝÒ×Ôì³É×ÊÔ´ËÀËø£¬»òÕßÑÏÖØÆÆ»µ¹ÌÓеijÌÐòÂß¼­¡£
> ´ó¼Ò²»Òª»¥ÏàÅúÆÀ£¬°üÈÝ°üÈÝ£¡£º£©
>
> -------------------------------------------------------------
> subject£ºRe: [python-chinese] ÐÂÊÖ£¬Çë½ÌÒ»¸ö×Ö·û´®´¦ÀíµÄÎÊÌâ
> Leo Jay
>
> On 8/2/06, Xiao Lei Wu <xiaoleiw at cn.ibm.com> wrote:
> >
> >  ÄãΪʲôҪ¼Ór£¿ÊÇΪÁËתÒåÂð£¿Ë­¸æËßÄãתÒåÓÃrµÄ£¿
> > Ò»°ãתÒ嶼ÓÃ\
> > ÕâÊdz£Ê¶
> >
> Errr, »ù±¾ÉÏ£¬Ëû¼ÓrÊÇΪÁ˲»ÒªÈÃ\תÒ壬¶ø²»ÊÇҪתÒå
> Äãˮƽ²»´í£¬µ«Ëµ»°µÄÓïÆøºÜÌÖÑá~~~
>
>
> --
> Best Regards,
> Leo Jay
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060802/ced431b3/attachment.html

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

2006年08月03日 星期四 00:51

Huang Cong mail.huangcong at gmail.com
Thu Aug 3 00:51:12 HKT 2006

分享一下,给不知道的人;可以用os.sep代替你的操作系统的目录分隔符,Linux、Unix下它是'/',在Windows下它是'\\',而在Mac
OS下它是':'。使用os.sep而非直接使用字符,会使我们的程序具有移植性,可以在上述这些系统下工作。--摘自《简明python教程》
http://www.woodpecker.org.cn:9081/doc/abyteofpython_cn/chinese/ch10s02.html#second

在06-8-2,Leo Jay <python.leojay at gmail.com> 写道:
>
>  On 8/2/06, Huang Cong <mail.huangcong at gmail.com> wrote:
>
> > 多谢Leo Jay,我加r是为了保留'\'字符而不转义,看了python
> > manual以后明白了,不能用r保留一个单独的'\'字符,因为'\'会把后面的"'"转义掉(好像是这样,不对欢迎大家说)
> >
> >
>
> 嗯,基本正确,确切的说是不能在字符串的最后面保留一个'\'字符,
> 像r'abcd\'也是不可以的
>
> --
> Best Regards,
> Leo Jay
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060803/88d7afc0/attachment.html

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

2006年08月03日 星期四 08:15

limodou limodou at gmail.com
Thu Aug 3 08:15:28 HKT 2006

On 8/3/06, Huang Cong <mail.huangcong at gmail.com> wrote:
> 分享一下,给不知道的人;可以用os.sep代替你的操作系统的目录分隔符,Linux、Unix下它是'/',在Windows下它是'\\',而在Mac
> OS下它是':'。使用os.sep而非直接使用字符,会使我们的程序具有移植性,可以在上述这些系统下工作。--摘自《简明python教程》
> http://www.woodpecker.org.cn:9081/doc/abyteofpython_cn/chinese/ch10s02.html#second
>
>
使用os.path.normcase可以自动帮你转换,不用考虑什么分隔符。

-- 
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

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

2006年08月03日 星期四 09:17

spring lee ncepu.lyc at gmail.com
Thu Aug 3 09:17:40 HKT 2006

os.path.join(dir1,dir2)使用分隔符os.sep连接两个目录
os.path.normcase
(path)将path转换为适合系统的标准形式:unix下面将保持不变,win下面(大小写不敏感的系统)所有字母转为小写,并将正斜杠"/"转换为反斜杠"\\"


On 03/08/06, limodou <limodou at gmail.com> wrote:
>
> On 8/3/06, Huang Cong <mail.huangcong at gmail.com> wrote:
> >
> 分享一下,给不知道的人;可以用os.sep代替你的操作系统的目录分隔符,Linux、Unix下它是'/',在Windows下它是'\\',而在Mac
> > OS下它是':'。使用os.sep而非直接使用字符,会使我们的程序具有移植性,可以在上述这些系统下工作。--摘自《简明python教程》
> >
> http://www.woodpecker.org.cn:9081/doc/abyteofpython_cn/chinese/ch10s02.html#second
> >
> >
> 使用os.path.normcase可以自动帮你转换,不用考虑什么分隔符。
>
> --
> I like python!
> My Blog: http://www.donews.net/limodou
> My Django Site: http://www.djangocn.org
> NewEdit Maillist: http://groups.google.com/group/NewEdit
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060803/d4becbff/attachment.htm

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号