hfsc | HFSC traffic shaping helper script
kandi X-RAY | hfsc Summary
kandi X-RAY | hfsc Summary
HFSC traffic shaping helper script.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of hfsc
hfsc Key Features
hfsc Examples and Code Snippets
Community Discussions
Trending Discussions on hfsc
QUESTION
My question is about how to open a file, change a variable in a line.
Example:
Modelica.SIunits.Height Hfsc = 3.7 "ground floor";
I need to change the Hfsc = 3.7
to Height_1 = 2
and then save the changes in a new file.
It should be something like this:
Modelica.SIunits.Height Height_1 = 2 "ground floor";
ANSWER
Answered 2017-Oct-29 at 21:20I suggest that you use regular expressions for the substitution and then write to the file. You could then simultaneously open two files, substitute and write to the new file like so:
import re
to_sub = 'parameter Modelica.SIunits.Height Hfsc = 3.7 "ground floor"'
replacement = 'parameter Modelica.SIunits.Height Height_1 = 2 "ground floor"'
with open(in_path, 'r') as inf, open(out_path, 'w') as outf:
for line in inf:
subbed_line = re.sub(to_sub, replacement, line)
outf.write(subbed_line)
Hope you found this helpful!
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install hfsc
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page