Created
February 10, 2019 08:33
-
-
Save Robofied/c8b742040a0b753f97ba15b3d5a15809 to your computer and use it in GitHub Desktop.
Intermediate Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Creating a string variable | |
b = 'Learn!' | |
## In this string value case str is giving output without '' but repr is giving output with '' | |
print(str(b)) | |
#[Output]: | |
#Learn! | |
## In this string value case str is giving output without '' but repr is giving output with '' | |
print(repr(b)) | |
#[Output]: | |
#'Learn!' | |
## Importing date and time module to get today's date and recent time. | |
import datetime | |
## Printing the value using str() function then it gives simply a value | |
print(str(datetime.datetime.now())) | |
#[Output]: | |
#2018-11-14 15:26:04.980581 | |
## Printing the value using repr() function then it is giving the type of object. | |
## Generally used for debugging mode by developers. | |
print(repr(datetime.datetime.now())) | |
#[Output]: | |
#datetime.datetime(2018, 11, 14, 15, 26, 15, 325797) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment