擅长:python、mysql、java
<p>如果你只有一个颜色词,你可以用这个词,你可以扩展n个颜色词的逻辑:</p>
<pre><code>our_str = "Ohhh that's the one Johnson told us about...can you send it to me?"
def colour_one(our_str):
if "one" in our_str:
str1, str2 = our_str.split("one")
new_str = str1 + Fore.RED + 'one' + Style.RESET_ALL + str2
else:
new_str = our_str
return new_str
</code></pre>
<p>我认为这是一个丑陋的解决方案,甚至不确定它是否有效。但如果你找不到其他东西,这是个解决办法。在</p>