需要澄清存储为错误值的python变量,代码如下:
userinput1 = int(input('enter start value\n'))
userinput2 = int(input('enter stop value\n'))
userinput3 = int(input('enter rampup time in seconds\n'))
userinput4 = float(input('enter increments delta \n'))
userinput5 = input('Enter sequence channels: A A A A or D D D D - A Ascend, D Descent , E Exclude \n')
command1 = "RAMP " + str(userinput5) + " " + userinput1 + " " + userinput2 + " " + userinput4 + " " + userinput3
port.write(command1.encode())
#### ERROR #####
command1 = str("RAMP " + str(userinput5) + " " + userinput1 + " " + userinput2 + " " + userinput4 + " " + userinput3)
TypeError: can only concatenate str (not "int") to str
您能给我澄清一下在单变量命令中存储两种类型变量输入的正确方法吗。类型种姓已经完成
您只能关联字符串,因此在关联所有用户输入之前,必须将它们“转换”为字符串
例1:
例2:
相关问题 更多 >
编程相关推荐