我想弄清楚当既有整数又有字符串时如何从输入中取出整数。
例如,如果我输入“hello 3”,有没有办法将“3”与“hello”之外的另一个变量分开?
答案 0 :(得分:0)
这对你有用吗:
myInput=input() # Get Input
myString,myIntStr=myInput.split(" ") # Split in to list based on where the spaces are
myInt=int(myIntStr) # Convert to int