From
What is the best way to remove accents in a Python unicode string? - Stack Overflow
oefe's response
z <SPAN class="operator token">=</SPAN> "áéíóúñ<SPAN class="comment token">#/" # ---- an example</SPAN> <SPAN class="keyword token">import</SPAN> unicodedata <SPAN class="keyword token">def</SPAN> <SPAN class="token function">strip_accents</SPAN><SPAN class="punctuation token">(</SPAN>s<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="string token">''</SPAN><SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>c <SPAN class="keyword token">for</SPAN> c <SPAN class="keyword token">in</SPAN> unicodedata<SPAN class="punctuation token">.</SPAN>normalize<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'NFD'</SPAN><SPAN class="punctuation token">,</SPAN> s<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> unicodedata<SPAN class="punctuation token">.</SPAN>category<SPAN class="punctuation token">(</SPAN>c<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">!=</SPAN> <SPAN class="string token">'Mn'</SPAN><SPAN class="punctuation token">)</SPAN> strip_accents<SPAN class="punctuation token">(</SPAN>z<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># ---- example output</SPAN> 'aeioun<SPAN class="comment token">#/'</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
RTM RTM, it appears Dan's reply answered your question. If so, please mark it correct to close out the question. If not, what didn't work?
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.