Prints the result but does not write it in txt

Viewed 30
import os
s = os.listdir("Desktop\mama\qwe")
f = open("asd.txt", "w")
for i in range(0, 100):
    try:
        print(os.listdir("Desktop\mama\qwe\ ".strip() + s[i] + "\Wallets"))
        f.writelines(s[i] + ":" + "\n")
        f.writelines(os.listdir("Desktop\mama\qwe\ ".strip() + s[i] + "\Wallets"))
        f.writelines("\n" + "\n")
    except:
        pass

with print(os.listdir("Desktop\mama\qwe\ ".strip() + s[i] + "\Wallets")) it works and it writes in console but f.writelines do not seem to work.

0 Answers
Related