V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
domino
V2EX  ›  Python

如何过滤特殊文件名

  •  
  •   domino · 2017-07-29 13:11:01 +08:00 · 2219 次点击
    这是一个创建于 2434 天前的主题,其中的信息可能已经有所发展或是发生改变。
    请问如何过滤爬虫爬回来,有特殊符号的标题的数据呢,
    想用标题建立文件夹,
    但有时候会遇特特殊字元无法建立.
    除了用 replace , 还有什么方法呢?
    7 条回复    2017-07-31 00:30:38 +08:00
    ysc3839
        1
    ysc3839  
       2017-07-29 15:12:19 +08:00
    CRC32 Hash 后作为文件夹名
    yangff
        2
    yangff  
       2017-07-29 15:56:19 +08:00
    base64 一下非扩展名部分?
    lazzyboy
        3
    lazzyboy  
       2017-07-29 16:01:42 +08:00
    额,没有`fnameescape() ` 么?
    techmoe
        4
    techmoe  
       2017-07-30 00:09:20 +08:00 via Android
    特殊符号转译呗。。还能有啥办法
    domino
        5
    domino  
    OP
       2017-07-30 14:27:33 +08:00
    如果用 md5 还是 crc 当为文件夹名,这样资料多很难识别.
    不知是否可以用排除特殊服号的方式来做?
    刚学 python,不是很熟.
    AnyOfYou
        6
    AnyOfYou  
       2017-07-31 00:12:39 +08:00
    domino
        7
    domino  
    OP
       2017-07-31 00:30:38 +08:00
    @AnyOfYou
    这篇文章我看过,
    不过这样的做法似乎无法保存中文,日文等文件名
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1146 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 18:35 · PVG 02:35 · LAX 11:35 · JFK 14:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.