时间:2025-04-26 00:06:56
Python中str.replace()的使用方法
target = today + os.sep + now + '_' + comment.replace(' ', '_') + '.zip' #today 被定义为根目录+今日时间,同理,now定义为为此时时间,例如为09.01.16:34:00则Linux中 target=根目录+0901/163300,将comment中的‘ ’替换为'_'目的是防止建文件夹失败(文件夹名不允许有空格 )Python replace() 方法把字符串中的 old(旧字符串) 替换成 new(新字符串),如果指定第三个参数max,则替换不超过 max 次。
《str.replace()的用法》不代表本网站观点,如有侵权请联系我们删除
精彩推荐
点击排行