Backwards-compatible input calls in Python

后端 未结 4 1741
囚心锁ツ
囚心锁ツ 2020-12-01 18:12

I was wondering if anyone has suggestions for writing a backwards-compatible input() call for retrieving a filepath?

In Python 2.x, raw_input worked fine for input l

4条回答
  •  不思量自难忘°
    2020-12-01 18:28

    The way you are handling it is just fine. There are probably more similar ways using the sys module, but just in keep in mind that if you are program is doing something more than trivial with strings and files, it is better to have two versions of your program instead of having a backwards compatible python3 program.

提交回复
热议问题