python

A collection of 4 posts
python

Python でdatetime.utcnow().isoformat()するとタイムゾーンが無い

ISO8601DateTimeで日付を渡すとき、pythonでハマったというか。 >>> from datetime import datetime >>> print datetime.utcnow().isoformat() 2016-06-17T04:00:50.691886 UTCなのに末尾に Z もなければ +00:00 もつかない StackOverflow 検証 % python Python 2.7.11 (default, Mar 10 2016, 20:29:25) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin Type
1 min read
python

pyenv&virtualenv use upgrade

ローカル環境にmoinmoinを入れようと思ってvirtualenvを作ったところきになるoutputがあった@Mac $ pyenv virtualenv 2.7.9 moin New python executable in /Users//.pyenv/versions/moin/bin/python2.7 Also creating executable in /Users//.pyenv/versions/moin/bin/python Installing setuptools, pip...done. Ignoring indexes: https://pypi.python.org/simple/ Requirement already satisfied (use --upgrade to upgrade): setuptools in /Users/
python

Pythonのエンコードを宣言する

Pythonでファイルのエンコードを宣言するとき # -*- coding: utf-8 -*- こういった内容を記載する人が多いと思いますが、自分にはこの記法には疑問がありました。 なぜEmacsを使わない人たちがEmacsのエンコードを宣言をするのだろうか。 会社ではEmacsを使うのは自分だけなので、もしかしたらこの記法がPythonのエンコード宣言だと思っているのかもしれません。 Vimではこう書く(らしい)です(Vimはほぼ使わないので知りません # vim:fileencoding= Pythonのリファレンス 英文 If a comment in the first or second line of the Python script matches the regular expression coding[=:]\s*([-\w.]+), this comment is processed as an encoding declaration; the
1 min read