So I am trying to use the current date to generate an order number for my restaurant system but it prints it with dashes and I don't know how to remove those. My current code for the date is below.
today = date.today
Whenever I print this the date prints out with dashes. Is there a way to remove those dashes from the code?
CodePudding user response:
You can use the strftime
method of the date
object.
>>> today = date.today()
>>> today.strftime("%d/%m/%Y")
'28/03/2022'
Here's the documentation on the format codes you can use.
CodePudding user response:
there is a better way, try this code below.
import datetime
mylist = []
today = datetime.date.today()
mylist.append(today)
print(mylist)
Hope that worked!