开发者

Split/Reformat String

I want to split a string and replac开发者_运维百科e some values. The string is a date that looks like this '08/26/2009' I want to reformat it so that it replaces the / with a - so that it looks like this '08-26-2009'

The string is passed into a variable y, so my line looks like this

test = y.split("/")
print y

return this ['8', '26', '2009']

I just can't figure out how to reformat it to place the dash between the day month and year.

Thanks Mike


You can use replace instead of split.

test = y.replace('/', '-');

(assuming this is Java)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜