1

# 以下の行は、TIBCO Spotfire テーブルを反復処理して、列と列のプロパティを取得します。そのうちの 1 つは、列の「計算式」プロパティです。

  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 に答える