クソ機械翻訳サイト追放運動

まずはこの日本語らしき文章を読んでみよう。意味分かりますか?

私は非常に単純なPythonのプログラムを複数のレコードをこのようにフォーマットされたASCII文字csvファイルを読み込むために書いている:

"2010年3月13日には、0.0.0、10.1、12.2、9.9、10.1、2500"日付、時刻、オープン、高、低、近い、ボリュームのフィールドを毎日株価の一覧、すなわち#

私は名前のファイルをアスキーから各行を読み取るためにfこのPythonのコードを使用します:

行fの:dは、トンは、o、時間、リットル、cのvは= line.split (',')#ここで、dは、日付、等の略

多くは、私の快適な衝撃に、ASCII文字列"2010年3月13日は"datetime.dateとして変数'd'を格納オブジェクトを終了します。

では、どのようでしたこの気持が良い驚きが起こる?なぜ、文字列'd'の文字列として"2010年3月13日"の代わりに格納されません日付オブジェクトとして?

Pythonは周り私は戻ってautomagical型変換を行うの背後が、こっそりする必要がありますそれが起こってどのように/どこにですか?

ありがとう!

ところで、私は"インポート日時"私はすべての醜い日付変換を自分自身を行うには計画していたからです。だからこそ、私は嬉しい驚きてるのよ。

どうやらこちらが原文らしい。

I'm writing a very simple python program to read in an ascii csv file with multiple records formatted like this:

"2010.3.13, 0.0.0, 10.1, 12.2, 9.9, 10.1, 2500" # i.e. a list of daily stock prices with date,time,open,high,low,close,volume fields

I use this python code to read each line from the ascii file named f:

for line in f: d,t,o,h,l,c,v = line.split(',') # where d stands for date, etc

Much to my pleasant shock, the ascii string "2010.3.13" ends up as a datetime.date object stored in the variable 'd'.

So, how did this pleasant surprise happen? Why isn't that string stored in 'd' as the string "2010.3.13" instead of as a date object?

Python must be sneaking around behind my back doing automagical type conversions, but how/where is it happening?

Thanks!

BTW, I did "import datetime" because I was planning to do all the ugly date conversions myself. That's why I'm pleasantly surprised.


→こういうクソ機械翻訳サイトはこの世から消えていただきたいのだが、みなさんはどのように考えますか?