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.
文字列を分割し、いくつかの値を置き換えたい。文字列は「08/26/2009」のような日付です。/ を - に置き換えるように再フォーマットして、「08-26-2009」のようにします。
文字列は変数 y に渡されるため、私の行は次のようになります
test = y.split("/") print y
これを返す ['8', '26', '2009']
日月と年の間にダッシュを配置するように再フォーマットする方法がわかりません。
ありがとうマイク
分割の代わりに置換を使用できます。
test = y.replace('/', '-');
(これがJavaであると仮定)