擅长:python、mysql、java
<p>您可以在Java中使用<a href="https://docs.oracle.com/javase/8/docs/api/java/io/PrintStream.html#printf-java.lang.String-java.lang.Object...-" rel="nofollow noreferrer">printf</a>。它在内部执行<code>String.format()</code>,因此您可以用与Python(或任何具有类似printf功能的语言)几乎相同的方式编写</p>
<pre><code>String words = "these words";
System.out.printf("I want to substitute %s!", words);
</code></pre>