6
Follow
16
Followers
파이썬에서 API 문서에서 코드를 테스트하는 초보자, 오류가 발생하면 도움을 요청하십시오.
import matplotlib.pyplot as plt
import json
def main():
plt.plot([3,6,2,4,7,1])
LogStatus(plt)
table = {type: 'table', title: '보장 정보', cols: ['열1, '열2'], rows: [ ['abc', 'def'], ['ABC', 'support color #ff0000']]}
LogStatus('' + JSON.stringify(table)+'') # JSON 서열화 후 양쪽을 더함字符, 视为一个复杂消息格式(当前支持表格) LogStatus('第一行消息\n' + JSON.stringify(table)+'\n第三行消息') # 表格信息也可以在多行中出现 LogStatus('' + JSON.stringify([table, table])+'`') # 여러 표를 동시에 표시할 수 있습니다. TAB로 그룹으로 표시됩니다.
Related Recommendations
Comment
All comments (1)

第一眼看到 代码,发现 问题应该是 你写的时候 单引号 ' 使用 中文输入了 ‘ , 这两个字符是不一样的,所以初学者需要注意的是 编程的时候一定 是 英文状态的输入法。
并且在代码编辑框可以提前看出来, 出现这样的红色的字符 颜色提示 一般都是很明显的错误。
代码中还有几处错误
正确的代码:
import matplotlib.pyplot as plt
import json
def main():
plt.plot([3,6,2,4,7,1])
LogStatus(plt)
table = {"type" : 'table', "title": '持仓信息', "cols": ['列1', '列2'], "rows": [ ['abc', 'def'], ['ABC', 'support color #ff0000']]}
LogStatus('`' + json.dumps(table) + '`') # JSON序列化后两边加上字符, 视为一个复杂消息格式(当前支持表格) LogStatus('第一行消息\n‘ + JSON.stringify(table)+’\n第三行消息') # 表格信息也可以在多行中出现 LogStatus('‘ + JSON.stringify([table, table])+’`’) # 支持多个表格同时显示, 将以TAB显示到一组里
9 years ago
- 1

