Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
初学者的一个非常简单的问题。
我正在尝试从文本文件中读取一个简单的数字,用它做一些数学运算并写回答案。
我知道这听起来很容易,但我是一个真正的初学者。
提前致谢
米歇尔
with open('data.txt') as f: num = int(f.readline()) # perform calculations with open('data.txt', 'w') as f: print >>f, num