如何使“file.write(repr(fieldNames1))”将我输入的内容写入“fieldNames1”?
import easygui
#Multi Enter Box
fieldNames1= ['Situation:(Example: Waiting for a friend who is late.)','Thoughts:(EXAMPLE: My friend Bob is always late!)','Emotions:(EXAMPLE: Mad & Stressed)','Behavior:(EXAMPLE: Arguing with family)']
#Write to file
file = open('Fieldnames test.txt', 'a')
file.write(repr(fieldNames1))
file.close()
无论我在“fieldnNames1”中输入什么,都使用以下文本创建一个名为“Fieldnames test.txt”的文件。
['情况:(示例:等待迟到的朋友。)','想法:(示例:我的朋友鲍勃总是迟到!)','情绪:(示例:疯狂和压力)','行为:(示例:与家人争吵)']