re.sub not replacing all occurrences

前端 未结 4 1993

I\'m not a Python developer, but I\'m using a Python script to convert SQLite to MySQL

The suggested script gets close, but no cigar, as they say.

The line g

4条回答
  •  太阳男子
    2021-01-02 02:30

    How about

    line = line.replace("'t'", "THIS_IS_TRUE").replace("'f'", "THIS_IS_FALSE")
    

    without using re. This replaces all occurrences of 't' and 'f'. Just make sure that no car is named t.

提交回复
热议问题