【发布时间】:2018-01-23 23:07:17
【问题描述】:
在python中我可以做以下事情
print "%02d:%02d" % (9, 6) # will output 09:06
如何在 TypeScript 中做到这一点?
【问题讨论】:
标签: typescript
在python中我可以做以下事情
print "%02d:%02d" % (9, 6) # will output 09:06
如何在 TypeScript 中做到这一点?
【问题讨论】:
标签: typescript
使用sprintf-js 库和types。
【讨论】:
FIDDLE: https://jsfiddle.net/1ytxfcwx/
NPM: https://www.npmjs.com/package/typescript-string-operations
GITHUB: https://github.com/sevensc/typescript-string-operations
使用模板字符串 -> https://basarat.gitbooks.io/typescript/content/docs/template-strings.html
或者你可以使用一个写的类 -> String.Format not work in TypeScript
或者使用我的 NPM 包!
https://www.npmjs.com/package/typescript-string-operations
var value = String.Format("{0:L}", "APPLE"); //output "apple"
【讨论】: