擅长:python、mysql、java
<pre><code>def main():
print("Please enter a number using the word 'thousand' or 'million'.")
number = input("For example, 1 million or 1 thousand: ")
data = number.split(" ")
if data[1] == str.lower('thousand'):
data[1] = ',000'
reply = ((data[0]) + data[1])
# print(f"{reply:,}")
print(reply)
main()
</code></pre>
<p>现在打印0。
您必须添加000作为字符串</p>
<p>或</p>
<pre><code>def main():
print("Please enter a number using the word 'thousand' or 'million'.")
number = input("For example, 1 million or 1 thousand: ")
data = number.split(" ")
if data[1] == str.lower('thousand'):
data[1] = '000'
reply = int(str(data[0])+data[1])
numbers = "{:,}".format(reply)
# print(f"{reply:,}")
print(numbers)
main()
</code></pre>