python-3.x - 设置变量时的Python语法错误
问题描述
当我尝试用等号回显一个数字时,会发生此错误:
printThis = "=" +str(result)
^
SyntaxError: invalid syntax
我试图这样做print("=" +str(result))
,它会出现类似的错误。
任何人都可以帮忙吗?谢谢!
编辑:
elif calc == "base":
base = int(input('''What base would you like to use?
Available: 2 (binary) 8 (octo) 10 (decimal (normal)) 16 (hex)
Type 2, 8, 10, or 16: '''))
if base == 2:
result = bin(input("Type the original number: ")
printThis = "=" +str(result)
print(printThis)
解决方案
关闭代码中以下行末尾的括号
result = bin(input("Type the original number: "))
推荐阅读
- python - TypeError:“球”对象不可调用?
- pandas - 根据 x 轴将两个不同日期的两条轨迹绘制到一张图上
- sql - SQL - Oracle比较一张表的两列中的数据
- java - 如何在Java中对像素进行算术运算
- python-3.x - Import Random 处理我相同的数字
- php - 理解PHP中对象使用的问题
- lucene - TermRangeQuery 有什么问题?
- sql - 当某些日期不存在时,Windows 函数按日期排序
- java - 使用 Cmake 在 Windows x64 上为 Java 构建 OpenCV
- javascript - html2canvas 并不总是正确生成图像