Python Forum
How can and I read and write css files
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can and I read and write css files
#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; }
Reply


Messages In This Thread
RE: How can and I read and write css files - by snippsat - May-04-2020, 11:10 PM

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

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020