Python 3.5, ctypes: TypeError: bytes or integer address expected instead of str instance

前端 未结 2 2036
庸人自扰
庸人自扰 2020-12-30 08:28

I\'m having an issue with ctypes. I think my type conversion is correct and the error isn\'t making sense to me. Error on line \" arg - ct.c_char_p(logfilepath) \" TypeErro

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-30 08:52

    c_char_p takes bytes object so you have to convert your string to bytes first:

    ct.c_char_p(logfilepath.encode('utf-8'))
    

    Another solution is using the c_wchar_p type which takes a string.

提交回复
热议问题