Python3中创建文件夹目录的时候特殊符号处理转义

版权声明:版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/z564359805/article/details/89466104
# 创建目录的时候,不能包含一些特殊字符要转义
news_title = ''
char_list = ['*','|',':','?','/','<','>','"','\\']
news_title_result = news_title
for i in char_list:
    if i in news_title :
        news_title_result = news_title.replace(i,"_")

猜你喜欢

转载自blog.csdn.net/z564359805/article/details/89466104