gpt4 book ai didi

Python TypeError : must be string, 不是 int

转载 作者:行者123 更新时间:2023-11-28 19:02:44 25 4
gpt4 key购买 nike

我有一个非常简单的脚本,我正在执行其他 4 个脚本。

第 17 行抛出此错误:TypeError: must be string, not int

这是第 17 行的全部内容:

execfile(c)

它执行前两个脚本(ab)没有问题,但在 c 上失败。如果我注释掉前两行脚本,它将成功运行第 17 行。

有什么想法吗?

整个脚本:

import datetime

today = str(datetime.datetime.today().strftime('%Y-%m-%d %H:%M'))

a = r'\\server\Scheduled_Scripts\PowerBI_part1.py'
b = r'\\server\Scheduled_Scripts\PowerBI_part2.py'
c = r'\\server\Scheduled_Scripts\PowerBI_part3.py'
d = r'\\server\Scheduled_Scripts\PowerBI_part4.py'

print "Starting at " + today

print "Executing part 1..."
execfile(a)
print "Executing part 2..."
execfile(b)
print "Executing part 3..."
execfile(c)
print "Executing part 4..."
execfile(d)

print "Complete at " + today

最佳答案

检查不同脚本中变量之间的命名冲突。尝试仅使用 a 运行它并仅使用 b 运行它以查看导致问题的原因,然后查看这两个脚本。如果它们都在同一个命名空间中运行,很可能您使用了相同的变量名或函数名两次,并且在之前的脚本中将应该是字符串的内容声明为整数。

此外,您是否考虑过将所有内容分组到函数中,然后只导入其他脚本?

关于Python TypeError : must be string, 不是 int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50762741/

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