0
f.write(str(Path))
f.write("\n")
f.write(str(Monthly))

path is a string but Monthly is date. I can Insert all in a text file but I am not getting the desired output:

The output that I wish should be

D:\python
2021-04-08

But the output that I get is

D:\python
               <---causing error is this gap 
2021-04-08

The extra line after the path is causing problems.

4

1 回答 1

0

您实际上使用了两个导致空白的换行符。您可以删除其中任何一个来解决问题以获得所需的输出。

f.write(str(Path))
f.write("\n")
f.write(str(Monthly))
于 2021-04-08T10:41:03.427 回答