gpt4 book ai didi

python - 在python 3中将raw_input()重命名为input()(版本检测)

转载 作者:行者123 更新时间:2023-11-30 23:29:48 25 4
gpt4 key购买 nike

我希望有一种通过 python <3 和 >=3 使用输入的统一方法。除了版本检测之外,还有其他更干净的方法可以做到这一点:

if sys.version_info[0] < 3:
raw_input("Press Enter to continue...");
else:
input("Press Enter to continue...");

最佳答案

sixfuture库或多或少会为您处理这个问题(以及许多其他跨版本问题)。

关于python - 在python 3中将raw_input()重命名为input()(版本检测),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20963349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com