python - 如何在用户给出的输入中的两个字符之间放置一个空格?我的错误在哪里??(我是初学者
问题描述
# Read an integer:
a = int(input())
# Print a value:
print(a[0] + " " + a[1])
如您所见,我正在尝试使用字符串放置空格,但出现错误,如下所示:
Traceback (most recent call last):
File "python", line 4, in <module>
TypeError: 'int' object is not subscriptable
解决方案
推荐阅读
- c# - for循环按顺序打印最后一个数字
- java - 反转单链表 [Java]
- r - 在 R 中的谷歌地图中按多边形显示区域限制区域
- java - SimpleDateFormat:解析日期字符串引发异常
- c# - Itext:遍历行并获取链接值
- google-cloud-dataflow - 使用 Pub/Sub 将 .csv 文件流式传输到 Cloud Storage
- android - 在进行第二个活动之前验证电子邮件地址
- c# - 我可以以某种方式对基本构造函数使用 Object Initialiser 语法吗?
- html - 为什么 href="/" 指向系统文件?
- mysql - 如何选择相反的(或不在的)一组结果?