我想把字符串'one two three'转换成one_two_three.
我试过了"_".join('one two three'),但那给了我o_n_e_ _t_w_o_ _t_h_r_e_e_......
如何"_"在字符串中的单词之间插入空格?
我想从输入'x + y'中删除"+"符号,其中x和y是一个字符串(单个数字)并打印结果.
例如,我输入5 + 7它应该显示57
这是代码:
opr = input("Enter string").strip("+")
print(opr)
Run Code Online (Sandbox Code Playgroud)
此代码未删除"+"符号请帮忙!
我需要在字符串中的 X 之间添加一个空格。该程序在一个字段中进行测量,在进行计算之前,我需要能够将整数与“x”分开。
例如:“12x24”应为“12 x 24”