Action Script 3 中是否有类似 printf 的东西? [英] Is there something like printf in Action Script 3?

查看:25
本文介绍了Action Script 3 中是否有类似 printf 的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了一段时间,但在 Action Script 中没有找到类似 printf 的内容.

I searched it for while but didn't find anything like printf in Action Script.

这使得生成格式化字符串有点困难.

That makes it a little difficult to generate formated strings.

推荐答案

Printf-as 是处理此问题的第三方库.这里是 GitHub 存储库.来自自述文件:

Printf-as is a third-party library that will handle this. Here is the GitHub repo. From the README:

printf("You can also display numbers like PI: %f, and format them to a fixed precision, 
        such as PI with 3 decimal places %.3f", Math.PI, Math.PI);
// outputs: " You can also display numbers like PI: 3.141592653589793, 
// and format them to a fixed precision, such as PI with 3 decimal places 3.142"

它也适用于日期:

var date : Date = new Date();
printf("Today is %d/%m/%Y", date, date, date);

这篇关于Action Script 3 中是否有类似 printf 的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆