mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-24 10:01:38 +00:00
Merge pull request #3081 from thalesmello/patch-1
[pythonstatcomp/en] Improvements to syntax and comments
This commit is contained in:
commit
e6c27bb820
@ -38,18 +38,16 @@ r.text # raw page source
|
|||||||
print(r.text) # prettily formatted
|
print(r.text) # prettily formatted
|
||||||
# save the page source in a file:
|
# save the page source in a file:
|
||||||
os.getcwd() # check what's the working directory
|
os.getcwd() # check what's the working directory
|
||||||
f = open("learnxinyminutes.html", "wb")
|
with open("learnxinyminutes.html", "wb") as f:
|
||||||
f.write(r.text.encode("UTF-8"))
|
f.write(r.text.encode("UTF-8"))
|
||||||
f.close()
|
|
||||||
|
|
||||||
# downloading a csv
|
# downloading a csv
|
||||||
fp = "https://raw.githubusercontent.com/adambard/learnxinyminutes-docs/master/"
|
fp = "https://raw.githubusercontent.com/adambard/learnxinyminutes-docs/master/"
|
||||||
fn = "pets.csv"
|
fn = "pets.csv"
|
||||||
r = requests.get(fp + fn)
|
r = requests.get(fp + fn)
|
||||||
print(r.text)
|
print(r.text)
|
||||||
f = open(fn, "wb")
|
with open(fn, "wb") as f:
|
||||||
f.write(r.text.encode("UTF-8"))
|
f.write(r.text.encode("UTF-8"))
|
||||||
f.close()
|
|
||||||
|
|
||||||
""" for more on the requests module, including APIs, see
|
""" for more on the requests module, including APIs, see
|
||||||
http://docs.python-requests.org/en/latest/user/quickstart/
|
http://docs.python-requests.org/en/latest/user/quickstart/
|
||||||
@ -71,8 +69,8 @@ pets
|
|||||||
# 1 vesuvius 6 23 fish
|
# 1 vesuvius 6 23 fish
|
||||||
# 2 rex 5 34 dog
|
# 2 rex 5 34 dog
|
||||||
|
|
||||||
""" R users: note that Python, like most normal programming languages, starts
|
""" R users: note that Python, like most C-influenced programming languages, starts
|
||||||
indexing from 0. R is the unusual one for starting from 1.
|
indexing from 0. R starts indexing at 1 due to Fortran influence.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# two different ways to print out a column
|
# two different ways to print out a column
|
||||||
|
Loading…
Reference in New Issue
Block a user