这样貌似不行
fileHandle = open('test.txt', 'a')
fileHandle.write(str(type(abc)))
fileHandle.close()
你的变量abc是不是没定义?我试了一下可以打印 代码是这样的
a = str(type('abc'))
myfile = open('test.txt', 'w')
myfile.write(a)
myfile.close()
# define abc
abc = 123
with open('test.txt', 'a') as f:
f.write(str(type(abc)))