-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy path03_modules.py
More file actions
36 lines (26 loc) · 867 Bytes
/
03_modules.py
File metadata and controls
36 lines (26 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
In this exercise, you'll be playing around with the sys module,
which allows you to access many system specific variables and
methods, and the os module, which gives you access to lower-
level operating system functionality.
"""
import sys
# See docs for the sys module: https://docs.python.org/3.7/library/sys.html
# Print out the command line arguments in sys.argv, one per line:
print(sys.argv[0])
# Print out the OS platform you're using:
import platform
print(platform.system())
# Print out the version of Python you're using:
print(sys.version)
import os
# See the docs for the OS module: https://docs.python.org/3.7/library/os.html
# Print the current process ID
pid = os.getpid()
print(pid)
# Print the current working directory (cwd):
path = os.getcwd()
print(path)
# Print out your machine's login name
import getpass
print(getpass.getuser())