How to write a list to a text file exactly as it appears in python? -


i want able write list text file, appear if print out in console (with brackets , everything). reason being, need use list later on , has appear if being printed.

i've tried using csv module, couldn't formatted wanted.

any suggestions?

try using repr. repr "returns canonical string representation of object", should give same string gets printed when inspect things on interactive prompt.

file.write(repr(my_list)) 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -