s = input("请输入一个代币值:")
if "$" in s:
n = float(s.replace("$",""))
y = n*6.7744
print(f"¥{y:.2f}")
else:
n = float(s.replace("¥",""))
y = n/6.7744
print(f"${y:.2f}")
如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮
代码示例如下,接受$或¥开头的数字输入
有帮助望采纳~
a=input()
s=6.7744
if a.startswith('$'):
print(f'¥{float(a[1:])*s}')
elif a.startswith('¥'):
print(f'${float(a[1:])/s}')