押忍
iniファイルの読み出しに付いて教えてほしいです
URLをブラウザからコピーするとURLエンコードされた状態でコピーされます
これをそのままiniファイルに貼り付けると、configparserで読み出すときにエラーになってしまいます
[example]
url = https://example.com/%E3%81%82%E3%81%84%E3%81%86%E3%81%88%E3%81%8A/abcdefg/
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
ini['example']['url']
File "C:\Users\Mercury\AppData\Local\Programs\Python\Python38\lib\configparser.py", line 1255, in __getitem__
return self._parser.get(self._name, key)
File "C:\Users\Mercury\AppData\Local\Programs\Python\Python38\lib\configparser.py", line 799, in get
return self._interpolation.before_get(self, section, option, value,
File "C:\Users\Mercury\AppData\Local\Programs\Python\Python38\lib\configparser.py", line 395, in before_get
self._interpolate_some(parser, option, L, value, section, defaults, 1)
File "C:\Users\Mercury\AppData\Local\Programs\Python\Python38\lib\configparser.py", line 442, in _interpolate_some
raise InterpolationSyntaxError(
configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%E3%81%82%E3%81%84%E3%81%86%E3%81%88%E3%81%8A/abcdefg/'
今は仕方なく適当なサイトでURLデコードして貼り付けてますが、結構な手間です
手間かけずに巧くやる方法はないでしょうか
ちなみにデコードすると以下になります
https://example.com/あいうえお/abcdefg/
くだすれPython(超初心者用) その51【まず1嫁】
■ このスレッドは過去ログ倉庫に格納されています
645デフォルトの名無しさん
2020/11/30(月) 14:02:35.50ID:wCS2S4dQ■ このスレッドは過去ログ倉庫に格納されています
