这是我的第一个问题,所以请不要太残忍:-) (我试图在问题数据库中找到一些东西,但没有成功)。
请您告诉我,在法伦海特的输出温度中,如何去除生产线开始时的额外空间?如果可能的话-初学者的解决方案。
celsius = input('Enter Celsius temperature:\n')
fahrenheit = (float(celsius)*(9/5))+32
print('Fahrenheit temperature:\n',fahrenheit)
Enter Celsius temperature:
100
Fahrenheit temperature:
212.0提前谢谢你。
发布于 2022-03-14 12:57:49
您可以将sep (分隔符)设置为空str,因为默认情况下是空格,即替换
print('Fahrenheit temperature:\n',fahrenheit)使用
print('Fahrenheit temperature:\n',fahrenheit,sep='')发布于 2022-03-14 12:58:57
默认情况下,print函数在输出中放置一个空格分隔符。您可以使用两个print语句将输出放在两个单独的行上,或者提供一个覆盖值来删除空格。
print('Fahrenheit temperature:', fahrenheit, sep='\n')https://stackoverflow.com/questions/71468156
复制相似问题