Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
for j in Xjoints: j = substitute( XrigNamespace, j, '')
Substitute に相当する Python を書きたいと思っています。どんな提案でも大歓迎です。ありがとう!
正規表現の置換:
import re test = "Hello -%there%-" regularExpr = "-%.*%-" s1 = re.sub(regularExpr, "Mel", test) # Result: Hello Mel s2 = re.sub("foo", "Mel", test) # Result: Hello -%there%-
Python で同等のものを作成することは明らかに可能ですが、既に提供されている高レベルのライブラリが使用されます (この場合、確実にパフォーマンスが向上します)。