我是新来的。我有一个string
如下所示:
a= "1.1 Introduction 1.2 Inverse of a Non-Singular 1.3 Elementary Transformations 1.4 Applications 1.5 Applications of Matrices"
我希望在String
中的数字之前插入逗号。
我尝试过的代码:
a= "1.1 Introduction 1.2 Inverse of a Non-Singular 1.3 Elementary Transformations 1.4 Applications 1.5 Applications of Matrices"
b = ""
for i in a:
print(i)
try:
temp = int(i)
b = b+ ","+ temp
except:
b = b + i
但这是错误的。请帮我解决一些问题
所需输出:
"1.1 Introduction, 1.2 Inverse of a Non-Singular, 1.3 Elementary Transformations, 1.4 Applications, 1.5 Applications of Matrices"
这可能会有帮助:
相关问题 更多 >
编程相关推荐