ShuraBB Posted February 1, 2016 Share Posted February 1, 2016 print datetime.datetime.strptime('Mon Feb 01 21:13:30 2016', '%a %b %d %H:%M:%S %Y') В клиенте WoT получаем: ERROR: File "scripts/common/Lib/_strptime.py", line 325, in _strptime ERROR: ValueError: time data 'Mon Feb 01 21:13:30 2016' does not match format '%a %b %d %H:%M:%S %Y' В "родном питоне" получаем логичное "2016-02-01 21:13:30" ..... @ Quote Link to comment Short link Share on other sites More sharing options...
Ekspoint Posted February 1, 2016 Share Posted February 1, 2016 from time import strftime from time import localtime print strftime('%d.%m.%Y — %H:%M:%S', localtime()) не? @ Quote Link to comment Short link Share on other sites More sharing options...
ShuraBB Posted February 2, 2016 Author Share Posted February 2, 2016 (edited) datetime.strptime это обратная к strftime - дата из текстовой строки Задачка-то была простая: Из даты в формате time.time() с произвольным смещением в днях получить чистую дату. Решение тоже не сложное: import time, datetime Time = time.time() Delta = 12 print datetime.date.fromtimestamp(Time) + datetime.timedelta(days=Delta) Но факт остается фактом: datetime.datetime.strptime в клиенте не работает Edited February 2, 2016 by ShuraBB @ Quote Link to comment Short link Share on other sites More sharing options...
Helkar Posted February 2, 2016 Share Posted February 2, 2016 (edited) Но факт остается фактом: datetime.datetime.strptime в клиенте не работает а в русской локализации даты? Edited February 2, 2016 by Helkar @ Quote Link to comment Short link Share on other sites More sharing options...
ShuraBB Posted February 3, 2016 Author Share Posted February 3, 2016 >а в русской локализации даты? Не проверял. Собственно изначально было так: datetime.datetime.strptime(time.ctime(Time), '%a %b %d %H:%M:%S %Y') time.ctime(Time) выдает в английской ;-) @ Quote Link to comment Short link Share on other sites More sharing options...
Ekspoint Posted February 3, 2016 Share Posted February 3, 2016 Самое простое сделать replace @ Quote Link to comment Short link Share on other sites More sharing options...
ShuraBB Posted February 3, 2016 Author Share Posted February 3, 2016 >Самое простое сделать replace Я пошел другим путем: datetime.date.fromtimestamp(Time) :-))) @ Quote Link to comment Short link Share on other sites More sharing options...
Ekspoint Posted February 3, 2016 Share Posted February 3, 2016 >Самое простое сделать replaceЯ пошел другим путем: datetime.date.fromtimestamp(Time) :-)))и типо выдает на рус яз? @ Quote Link to comment Short link Share on other sites More sharing options...
ShuraBB Posted February 4, 2016 Author Share Posted February 4, 2016 Не, оно выдает как и нужно мне было переменную в формате date @ Quote Link to comment Short link Share on other sites More sharing options...
GPCracker Posted February 4, 2016 Share Posted February 4, 2016 Есть еще один момент... Попробуйте на питоне (чисто питоне) c помощью urllib скачать файл с FTP. А потом на клиенте игры. Та же самая херня. Короче, у картохи весьма кривые либы стоят, возможно просто очень старые или правленые кривыми руками картохиных индусов. Но их это не парит. Страдайте, ребят) Если конечно либа чисто питоновская, ее еще можно подкинуть, а вот если C... Тогда только обходными путями решать задачу. @ Quote Link to comment Short link Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.