【发布时间】:2017-09-06 07:01:27
【问题描述】:
我正在尝试创建一个程序来向新文件夹发送垃圾邮件,但我无法让它工作,我不断收到
TypeError: cannot concatenate 'str' and 'int' objects
但我已经将字符串金额转换为整数
import os
def folderSpam():
amount = raw_input("Please insert how many folders you want to create: ")
amount = int(amount)
path = raw_input("Please insert the directory to create the folders in: ")
msg = raw_input("Please insert the spam name of the folders")
for i in range(0, amount):
amount0 = 0
if amount0 == amount:
exit()
else:
amount0 = amount0 + 1
os.chdir(path)
os.mkdir(msg + amount0)
print "All folders have been created"
【问题讨论】:
-
错误很明显:
msg + amount0不起作用。试试这个:msg + str(amount0)
标签: python