Python:[email protected]
#!/usr/bin/env python
# *-# -*- coding: utf-8 -*-
# %%%{CotEditorXOutput=ReplaceSelection}%%%
from __future__ import print_function
import datetime
d=datetime.datetime.today()
print (d.strftime("%Y%m%d_"), end="")
Since Mac is Python2 by default, print functions that can be processed by Python3 cannot be processed as they are.
The scripts that can be processed are as follows. But this script contains line breaks. If there is no problem with line breaks, this is OK.
Python:[email protected]
print (d.strftime("%Y%m%d_")
In the print function of Python3, it is possible to omit line breaks by writing'end = ""'in the print function.
Python:[email protected]
print (d.strftime("%Y%m%d_"), end="")
But this script cannot be processed by CotEditor. So, if you declare the print function so that it can be processed in Python2, you can insert it in CotEditor without line breaks.
Python:[email protected]
from __future__ import print_function
Recommended Posts