小编Cra*_*aig的帖子

Python:在字符串格式化期间并非所有参数都被转换

我是一个脚本,它将当前的日期和时间保存为文件名,但是我收到一条错误,指出"TypeError:并非在字符串格式化过程中转换了所有参数"我是Python的新手并且可能错过了一些明显的东西.代码如下:

from subprocess import Popen
import datetime

today = datetime.date.today()

today = str(today)

print today

f = open("%s.sql", "w" % (today))
x =  Popen(["mysqldump", "-u", "root", "-pucsdrv", "normalisationtion"], stdout = f)
x.wait()
f.close()
Run Code Online (Sandbox Code Playgroud)

python string formatting datetime

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

无法使Crontab正常工作

我一直在尝试让crontab工作一段时间,但它似乎并不想工作。我需要在每个午夜初始化的python脚本可以从命令终端完美地工作。我的python脚本的位置是:

/home/rv/ncbi-blast-2.2.23+/database_backup/backup.py

我的contab看起来像这样:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/home/rv/ncbi-blast-2.2.23+/database_backup
MAILTO=root
HOME=/
# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  * …
Run Code Online (Sandbox Code Playgroud)

python linux crontab

5
推荐指数
1
解决办法
2257
查看次数

标签 统计

python ×2

crontab ×1

datetime ×1

formatting ×1

linux ×1

string ×1