You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何向字符串中添加感叹号?

给姓名添加感叹号的实现方法

不管用哪种编程语言,核心都是把姓名字符串和!拼接后输出,以下是几种常用语言的示例:

  • Python
name = "John"
print(f"{name}!")  # 输出 *John!*
  • JavaScript
const name = "John";
console.log(`${name}!`); // 输出 *John!*
  • Java
public class Main {
    public static void main(String[] args) {
        String name = "John";
        System.out.println(name + "!"); // 输出 *John!*
    }
}

如果需要在文本里强调格式化后的姓名,直接用*包裹结果即可,比如*John!*。

内容的提问来源于stack exchange,提问作者superior_light

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 21:01:54