1

# 下面的行遍历 TIBCO Spotfire 表,获取列和列属性,其中之一是列的“计算表达式”属性

  for tb in Document.Data.Tables:
    for col in tb.Columns:
      # initialize column variable
      ces = ""
      # get calculated expression and cast to string
      try:
        ces = col.Properties.CalculatedExpression.ToString()
      exception:
        ces="Error:Calculated Expression Not Read"

我事先知道一些计算表达式中有 unicode 字符(对此无能为力),所以我试图“捕捉”这些问题并简单地写出错误。
然后转到下一列。
但是,我继续收到以下错误,抱怨大于或等于符号:

System.Text.EncoderFallbackException:“ascii”编解码器无法在位置 174 编码字符“\u2264”

4

1 回答 1

2

没有解释它,但如果你尝试:

for tb in Document.Data.Tables:
for col in tb.Columns:
  # initialize column variable
  ces = ""
  # get calculated expression and cast to string
  try:
    ces = str(col.Properties.CalculatedExpression)
  exception:
    ces="Error:Calculated Expression Not Read"

反而?

如果这不起作用,请查看 unicode() 函数。

str() 文档 - https://ironpython-test.readthedocs.org/en/latest/library/functions.html#str

unicode() 文档 - https://ironpython-test.readthedocs.org/en/latest/library/functions.html#unicode

如果有给出的示例数据,我会自己测试它。

于 2014-03-19T16:40:15.187 回答