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
cico98
V2EX  ›  Python

to_csv(f'{self.output_dir}/{row["code"]}.{row["code_name"]}.csv', index=False)这里面的 code_name 中包含*这里报错要怎么处理啊。

  •  
  •   cico98 · 2020-05-18 23:27:25 +08:00 · 2099 次点击
    这是一个创建于 1428 天前的主题,其中的信息可能已经有所发展或是发生改变。
    4 条回复    2020-05-18 23:50:22 +08:00
    renmu
        1
    renmu  
       2020-05-18 23:32:46 +08:00 via Android
    不能做文件名的符号用个函数都过滤掉就好了
    customsshen
        2
    customsshen  
       2020-05-18 23:37:29 +08:00
    随便整一个相对路径文件名不行吗?
    ClericPy
        3
    ClericPy  
       2020-05-18 23:44:45 +08:00
    我直接无脑 re.sub(r'[^ \w]+', '_', name).strip() 替换了... 懒得去对比不同操作系统的安全文件名符号列表
    Trim21
        4
    Trim21  
       2020-05-18 23:50:22 +08:00 via Android
    那就用 replace 把星号删掉啊
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5416 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 07:06 · PVG 15:06 · LAX 00:06 · JFK 03:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.