python-3.x - 有没有办法在py3的开头打印没有空格?
问题描述
我的输出有问题。我必须打印两个整数的总和。但是输出总是在整数之前带有一个默认的空格。我该如何做对?
'''
i = 4
d = 4.0
s = 'HackerRank '
# Declare second integer, double, and String variables.
# Read and save an integer, double, and String to your variables.
e= int(input(' '))
g= float(input(' '))
h= str(input(' '))
# Print the sum of both integer variables on a new line.
p=i+e
print(p,end='\n')
# Print the sum of the double variables on a new line.
f=d+g
print(f)
# Concatenate and print the String variables on a new line
j= str(s)+str(h)
print(j)
# The 's' variable above should be printed first.
''' 输出:
6
7.0
HackerRank hi
我该怎么做才能删除整数'6'之前的空格
解决方案
当您进行此更改时,您会清楚地看到它。
e= int(input(' '))
g= float(input(' '))
h= str(input(' '))
改成:
e= int(input('Enter e:'))
g= float(input('Enter g:'))
h= str(input('Enter h:'))
推荐阅读
- r - 识别列中重复项的第一个实例
- filter - Pyorch:使用 conv2d 在一张图片上应用一批过滤器(内核)
- javascript - 使用 React 从 Firebase 获取数据
- keyboard - VBox 界面上的键盘映射
- android - DrawerLayout 菜单项在单击事件中不起作用
- reactjs - 如何在 react-testing-library 中获取具有“name”属性的元素
- vlc - 使用网络摄像头/hdmi-usb 加密狗时,帧率低(视频断断续续)、无声音、“图像中未找到 JPEG 数据”
- ios - 未安装私钥 Apple Distribution
- javascript - 在 AJAX 调用中从 (data) 中提取数组数据
- drupal - 是否有显示为 Drupal 核心发布的最新安全补丁的 RSS 提要