Py_BuildValue使用实例

例如:
Py_BuildValue("") None
Py_BuildValue(“i”, 123) 123 #数字
Py_BuildValue(“iii”, 123, 456, 789) (123, 456, 789) #元组
Py_BuildValue(“s”, “hello”) ‘hello’ #字符串
Py_BuildValue(“ss”, “hello”, “world”) (‘hello’, ‘world’) #元组
Py_BuildValue(“s#”, “hello”, 4) ‘hell’
Py_BuildValue(“u”,“D:\学习研究\”) 构造unicode类型的文本,当含有中文时使用,vs需要使用unicode编码生成程序。
Py_BuildValue("()") ()
Py_BuildValue("(i)", 123) (123,)
Py_BuildValue("(ii)", 123, 456) (123, 456)
Py_BuildValue("(i,i)", 123, 456) (123, 456)
Py_BuildValue("[i,i]", 123, 456) [123, 456] #列表
Py_BuildValue("{s:i,s:i}", “abc”, 123, “def”, 456) {‘abc’: 123, ‘def’: 456}#字典
Py_BuildValue("((ii)(ii)) (ii)", 1, 2, 3, 4, 5, 6) (((1, 2), (3, 4)), (5, 6))

猜你喜欢

转载自blog.csdn.net/haodawei123/article/details/88327232
py