2007年12月20日 星期四 09:59
ÎÒÓÃdjangoÉÏ´«Í¼Æ¬ºó£¨windowsÏÂÃæ)£¬µÃµ½µÄ·¾¶ÈçÏ£º '/media/upload\images\2007\12\19\DSC_3050stand.JPG' ÏÖÔÚÒª¸üÕýΪ£º '/media/upload/images/2007/12/19/DSC_3050stand.JPG' ÔÚ¿ØÖÆ̨ÀïÃæ¿ÉÒÔ r'/media/upload\images\2007\12\19\DSC_3050stand.JPG'.replace('\\','/') µ«ÊÇÏÖÔÚ path = '/media/upload\images\2007\12\19\DSC_3050stand.JPG' Ôõô±í´ïʽµÄ·½Ê½±ä³Éraw string ? ¸½£ºÄ£ÐÍÀïÃ棺 IMG_ROOT = "upload/images/%Y/%m/%d", photo_path = models.ImageField(_('photo'), upload_to=IMG_ROOT) ΪʲôÎÒ»á»ñµÃÕâ¸ö´íÎóµÄ·¾¶£¿ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20071220/79ca94b6/attachment.htm
2007年12月20日 星期四 10:15
http://www.python.org/doc/2.4/lib/os-path.html On Dec 20, 2007 12:59 PM, Youhong Han <python.han at gmail.com> wrote: > 我用django上传图片后(windows下面),得到的路径如下: > '/media/upload\images\2007\12\19\DSC_3050stand.JPG' > 现在要更正为: > '/media/upload/images/2007/12/19/DSC_3050stand.JPG' > 在控制台里面可以 > r'/media/upload\images\2007\12\19\DSC_3050stand.JPG'.replace('\\','/') > 但是现在 > path = '/media/upload\images\2007\12\19\DSC_3050stand.JPG' > 怎么表达式的方式变成raw string ? > > 附:模型里面: > IMG_ROOT = "upload/images/%Y/%m/%d", > photo_path = models.ImageField(_('photo'), upload_to=IMG_ROOT) > 为什么我会获得这个错误的路径? > > _______________________________________________ > 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.
2007年12月20日 星期四 11:11
ÄãûÓÐÃ÷°×ÎÒµÄÎÊÌâ¡£ÎÒÖªµÀwindowsϵķ¾¶·Ö¸î·ûºÏËÑ"\" On Dec 20, 2007 10:15 AM, xxmplus <xxmplus在gmail.com> wrote: > http://www.python.org/doc/2.4/lib/os-path.html > > On Dec 20, 2007 12:59 PM, Youhong Han <python.han在gmail.com> wrote: > > ÎÒÓÃdjangoÉÏ´«Í¼Æ¬ºó£¨windowsÏÂÃæ)£¬µÃµ½µÄ·¾¶ÈçÏ£º > > '/media/upload\images\2007\12\19\DSC_3050stand.JPG' > > ÏÖÔÚÒª¸üÕýΪ£º > > '/media/upload/images/2007/12/19/DSC_3050stand.JPG' > > ÔÚ¿ØÖÆ̨ÀïÃæ¿ÉÒÔ > > r'/media/upload\images\2007\12\19\DSC_3050stand.JPG'.replace('\\','/') > > µ«ÊÇÏÖÔÚ > > path = '/media/upload\images\2007\12\19\DSC_3050stand.JPG' > > Ôõô±í´ïʽµÄ·½Ê½±ä³Éraw string ? > > > > ¸½£ºÄ£ÐÍÀïÃ棺 > > IMG_ROOT = "upload/images/%Y/%m/%d", > > photo_path = models.ImageField(_('photo'), upload_to=IMG_ROOT) > > ΪʲôÎÒ»á»ñµÃÕâ¸ö´íÎóµÄ·¾¶£¿ > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在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. > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20071220/02be2a75/attachment.html
Zeuux © 2024
京ICP备05028076号