这是我的想法
由于某种原因,它必须采用这种形式
text=input("plz type:")
constant=30
if text == "!dollar "+**any integer**
print(any integer*constant)
如何使其正常工作
是否可以将“ if”用于这种要求?
并在进一步计算时获得整数
谢谢!
答案 0 :(得分:3)
您应该使用正则表达式:
import re
text = input("plz type:")
constant = 30
match = re.match(r'!dollar(\d+)', text)
if match:
print(int(match.group(1)) * constant)