小编use*_*269的帖子

Python 64 位?“在 win32 上”是什么意思?

团队,

我将重新雇用你们所有人。我对输入“python”一词后直接显示的横幅有疑问。激活交互式 shell 时会出现此横幅。

下面可以看到我当前安装中的横幅。我注意到在该行的末尾有几个词,on win32。这是在“键入“help”,...”行之前。这个“on win32”是否意味着Python运行在32位操作系统上?我检查了 Windows 安装的控制面板,发现操作系统是 64 位。我刚刚安装了 64 位的 Python,因此我相当确定 Python 应用程序是 64 位的。

Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Run Code Online (Sandbox Code Playgroud)

另外,我执行了以下命令,这显然意味着我正在运行 64 位版本的 Python。请看代码如下:

>>> import platform
>>> platform.architecture()
('64bit', 'WindowsPE')
Run Code Online (Sandbox Code Playgroud)

python python-2.7

5
推荐指数
0
解决办法
4223
查看次数

Python 脚本未在 cron 中运行

我正在尝试从 cron 运行 Python 脚本。我使用 crontab 以用户身份而不是 root 身份运行命令。我的 Python 脚本的顶部有 shebang #! /usr/bin/env python,我chmod +x这样做是为了使脚本可执行。

该脚本在从 shell 运行时确实有效,但在使用 crontab 时则无效。我确实检查了/var/log/cron文件,发现脚本运行了,但绝对没有任何内容stdoutstderr在任何地方打印。

最后,我制作了一个小脚本,用于打印日期和字符串,并每分钟调用该脚本,该脚本有效,但另一个脚本则无效。我不知道为什么我会得到这些可变的结果......

这是我的条目crontab

SHELL=/bin/bash



#min    #hour   day-of-month    month   day-of-week     command
#-------------------------------------------------------------------------
*/5     *       *                *        *             /path/to/script/script.py
Run Code Online (Sandbox Code Playgroud)

这是我的脚本的源代码,它不会从 crontab 运行,但会在像这样调用时从它所在的 shell 运行./script.pychmod +x顺便说一下,在我使用该命令后,该脚本是可执行的......:

#! /usr/bin/env python

#create a file and write to it
import time

def create_and_write():
    with open("py-write-out.out", "a+") as w:
        w.write("writing to file. hello …
Run Code Online (Sandbox Code Playgroud)

python bash shell cron

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×2

bash ×1

cron ×1

python-2.7 ×1

shell ×1