Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How can and I read and write css files
#1
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"
Age Doesn't Matter, Your Passion Does
- Shreya Jain
Quote
#2
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
Output:
body { background: #67B26F; } html { height: 100% } #wrapper { width: auto; }
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
Output:
body { background: #67B26F; } rubberduck { height: 100% } #wrapper { width: auto; }
Quote
#3
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.
Age Doesn't Matter, Your Passion Does
- Shreya Jain
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  audio read/write library Skaperen 7 490 Oct-21-2019, 06:22 AM
Last Post: Larz60+
  Using Python to read and analyze flow cytometry data files dtm04547 3 3,063 Feb-05-2019, 12:35 PM
Last Post: Shwager

Forum Jump:


Users browsing this thread: 1 Guest(s)