How do I convert a string to a buffer in Python 3.1?

后端 未结 2 1906
离开以前
离开以前 2021-01-17 17:52

I am attempting to pipe something to a subprocess using the following line:

p.communicate(\"insert into egg values (\'egg\');\");

TypeError: mu         


        
2条回答
  •  走了就别回头了
    2021-01-17 18:27

    You can convert it to bytes with encode method:

    >>> "insert into egg values ('egg');".encode('ascii')    # ascii is just an example
    b"insert into egg values ('egg');"
    

提交回复
热议问题