link > Python > 文字列操作 > ファイル名として無効な文字を削除 (別解法: a whitelist approach) + 使用例 (at ideone in Python 3.5)
1453 ワード
文字列から「ファイル名無効文字」を省く処理。
re.sub()を使った実装例を紹介されている。
関数などで簡単に「無効文字」が取得できないか?
関数ではないが、自作関数で「無効文字」を削除している例は見つかった。
ホワイトリストアプローチ
string.ascii_lettersまたはstring.digitsのみを妥当な文字としての処理
これが有効かは使用者のやりたいことによるだろう
注記: seanhによる実装では「空白」を「_」に変換もしている
ideone使用例
ideone(Python3.5)で使用してみた
https://ideone.com/BMRVGl
関連
Author And Source
この問題について(link > Python > 文字列操作 > ファイル名として無効な文字を削除 (別解法: a whitelist approach) + 使用例 (at ideone in Python 3.5)), 我々は、より多くの情報をここで見つけました https://qiita.com/7of9/items/c16b90c4c8e20bde3256著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .