简体   繁体   English

与 /usr/bin/python3.4 /usr/bin/python3 的区别

[英]Difference with /usr/bin/python3.4 /usr/bin/python3

My question is, what is the difference between /usr/bin/python3.6 and /usr/bin/python3.我的问题是,/usr/bin/python3.6 和/usr/bin/python3.6 之间有什么区别。 I am using cronjob for running python script.我正在使用 cronjob 来运行 python 脚本。 Script is not running under python 3.4 but it is running under 3.6 version.脚本不在 python 3.4 下运行,但在 3.6 版本下运行。 However whenever I am changing it to /usr/bin/python3 it is also running.但是,每当我将其更改为 /usr/bin/python3 时,它也在运行。

What should I use then in cronjob, exact version like 3.6 or just 3?那么我应该在 cronjob 中使用什么,确切的版本是 3.6 还是 3? What is best practice?什么是最佳实践? Thanks.谢谢。

/usr/bin/python3 is the platform default Python 3 installation. /usr/bin/python3是平台默认的 Python 3 安装。 It's often inadvisable to change it because of dependencies that other parts of the system may have on it, so it's often older than the latest release.由于系统的其他部分可能对其具有依赖性,因此通常不建议更改它,因此它通常比最新版本旧。 It's normally a symlink to a specific version, so if you want to know what version it actually is run:它通常是特定版本的符号链接,因此如果您想知道它实际运行的是哪个版本:

ls -al /usr/bin/python3

If you write scripts that need a later language or library versions than /usr/bin/python3 then you will need to install and specify a specific version to ensure you pick those up.如果您编写的脚本需要比/usr/bin/python3更高的语言或库版本,那么您将需要安装并指定特定版本以确保您选择这些版本。

Much beyond that I doubt it matters too much;除此之外,我怀疑它太重要了。 most distros backport security fixes to their default Python installation so the only reason to use a newer version is a desire to use the new features.大多数发行版将安全修复程序反向移植到其默认 Python 安装中,因此使用较新版本的唯一原因是希望使用新功能。

There is no best or worst practice.没有最好或最坏的做法。 It's a different python version.这是一个不同的python版本。 Use whichever works fine.使用哪个工作正常。

You can find the New Topics of python3.6 here你可以在 这里找到python3.6的新话题

Well for your query python3.6 has backward compatibility will all versions lower than 3.6那么对于您的查询 python3.6 具有向后兼容性将所有低于 3.6 的版本

Here is reference example relaed to literal这是与文字相关的参考示例

# python 3.7.4
>> platform="stackoverflow"
>> print(f"we are on {platform}")
we are on stackoverflow

# python 3.4.3
>> platform="stackoverflow"
>> print(f"we are on {platform}")
  File "main.py", line 1                                                                    
    print(f"we are on {platform}")                                                     
                                ^                                                      
SyntaxError: invalid syntax  

I hope this clarify your doubt我希望这能澄清你的疑惑

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM