How can and I read and write css files - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: How can and I read and write css files (/thread-26523.html) |
How can and I read and write css files - SheeppOSU - May-04-2020 I want to read and write with css files, but I don't know how I would do this since I get an error when I try to use redlines with a css files. I'd appreciate if someone could point me in the right direction. Thanks in advance.Edit: The error says "UnsupportedOperation: not readable" RE: How can and I read and write css files - snippsat - May-04-2020 CSS is just a text format,so can read and write in stander way. If you are not taking about how a web-framework read a CSS file? style.css
with open('style.css') as f: css_file = f.read() new = css_file.replace('html', 'rubberduck') with open('new.css', 'w') as f_out: f_out.write(new)new.css
RE: How can and I read and write css files - SheeppOSU - May-04-2020 Oh, I just realized how stupid I am. I had it on writing mode, I just changed it to w+ so I can read and write in it. |