I am fairly new to python. Was following the suggestions from here trying to force a string to be output with a single set of double quotes (e.g., "my_string"
) but it always ends up being printed as such: """my_string"""
Any idea why?
I tried:
'"' + my_string + '"'
and
f'"{self.args["name"]}"'
and str(my_string)
and "\"" + my_String + "\""
but same behavior:
"""my_string"""
Code snippet:
def print_out(self):
self.args = {}
self.args["name"] = 001
self.bla = 1
self.tra = 0
self.val = 0.12445
with open("my_file", "w") as fout:
tsv = csv.writer(fout, delimiter="\t")
tsv.writerow(["name", "bla", "tra", "hehe"])
tsv.writerow(
[f'"{self.args["name"]}"', self.bla, self.tra, round(self.val, 2)]
)
In the above example, the self.args["name"]
is printed as """001"""
Thanks