Answers for "python module for path command"

2

how to get module path in python

import a_module
print(a_module.__file__)
Posted by: Guest on November-27-2020
1

PYTHON INSTALL DIR = os.path.dirname(os.path.dirname(os.__file__)) AttributeError: module 'os' has no attribute '_file_'

# Python program to explain os.path.join() method  
    
# importing os module  
import os 
  
# Path 
path = "/home"
  
# Join various path components  
print(os.path.join(path, "User/Desktop", "file.txt"))
Posted by: Guest on August-29-2020
0

run python with options

import argparse
import sys

parser = argparse.ArgumentParser(description="Does some awesome things.")
parser.add_argument('message', type=str, help="pass a message into the script")

if __name__ == '__main__':
    args = parser.parse_args(sys.argv[1:])
    print args.message
Posted by: Guest on April-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language