From ecba01b4b1c35cbcf58c5e030b9e79a5c30be55c Mon Sep 17 00:00:00 2001 From: Braxton Fair Date: Sun, 28 Feb 2016 20:33:57 -0600 Subject: Write a bit better code --- pythonstatcomp.html.markdown | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'pythonstatcomp.html.markdown') diff --git a/pythonstatcomp.html.markdown b/pythonstatcomp.html.markdown index f8d83b98..0b02dca8 100644 --- a/pythonstatcomp.html.markdown +++ b/pythonstatcomp.html.markdown @@ -150,9 +150,8 @@ ggplot(aes(x="age",y="weight"), data=pets) + geom_point() + labs(title="pets") url = "https://raw.githubusercontent.com/e99n09/R-notes/master/data/hre.csv" r = requests.get(url) fp = "hre.csv" -f = open(fp, "wb") -f.write(r.text.encode("UTF-8")) -f.close() +with open(fp, "wb") as f: + f.write(r.text.encode("UTF-8")) hre = pd.read_csv(fp) -- cgit v1.2.3