MaxPlus WStr Python 中的字符串传递给 MaxPlus

MaxPlus WStr Python 中的字符串传递给 MaxPlus

  在 MaxPlus 中,很多方法的参数使用的字符串的类是 WStr,所以在 Python 中,我们传递字符串的时候,就要把 Python 的字符串类型转换为 WStr,

  而我们在构造 WStr 的时候,它的构造函数接受的参数类型为 WStr 或者 wchar_t,这里我们不讨论 WStr,这个 wchar_t 不是 MaxPlus 的类,从类型看出,它是 C 或者 C++ 的类型,那么,在 python 中就要把 python 的字符串类型转为 wchar_t

代码:

import MaxPlus

s = 'string'

wstr_s = MaxPlus.WStr(str(s))

经过上面的转换,我们就可以把 wstr_s 传递给 MaxPlus 的方法了,注意关键在于 str(s),我们不能直接把 s 传递给 WStr 的构造函数。

猜你喜欢

转载自www.cnblogs.com/ibingshan/p/11989774.html
今日推荐