This is a personal note.
(require '[clojure.string :as str])
(str/split "spam egg ham" #" ")
; ["spam" "egg" "ham"]
>>> "spam egg ham".split()
['spam', 'egg', 'ham']
(int (.charAt "Liquor" 0)
; 37202
(format "%x" (int (.charAt "Liquor" 0)))
; "9152"
>>> ord(u"Liquor")
37202
>>> hex(ord(u"Liquor"))
'0x9152'
Clojure
user=> (System/getProperty "java.io.tmpdir")
"/tmp"
For Clojure, using fs
seems to be more like Clojure.
user=> (require '[me.raynes.fs :as fs])
nil
user=> (fs/tmpdir)
"/tmp"
Python
>>> import tempfile
>>> tempfile.gettempdir()
'/tmp'
Don't just do your best with the standard library, Python dateutil, Clojure clj-time Isn't it better to use -time)?
(require '[clj-time.coerce :as c])
(require '[clj-time.local :as l])
(/ (c/to-long (l/to-local-date-time "2015-11-24T22:00:00+09:00")) 1000)
; 1448370000
>>> import dateutil.parser
>>> import time
>>> time.mktime(dateutil.parser.parse("2015-11-24T22:00:00+09:00").utctimetuple())
1448370000.0
(require '[clj-time.coerce :as c])
(c/from-long (* 1448370000 1000))
; #object[org.joda.time.DateTime 0x6f5185fe "2015-11-24T13:00:00.000Z"]
>>> import datetime
>>> datetime.datetime.utcfromtimestamp(1448370000.0)
datetime.datetime(2015, 11, 24, 13, 0)
Recommended Posts