Python, writing an integer to a '.txt' file

前端 未结 5 1226
礼貌的吻别
礼貌的吻别 2021-02-20 03:20

Would using the pickle function be the fastest and most robust way to write an integer to a text file?

Here is the syntax I have so far:

import pickle

p         


        
5条回答
  •  我在风中等你
    2021-02-20 03:58

    The following opens a while and appends the following number to it.

    def writeNums(*args):
    with open('f.txt','a') as f:
        f.write('\n'.join([str(n) for n in args])+'\n')
    
    writeNums(input("Enter a numer:"))
    

提交回复
热议问题