strptime()을 사용한 DateTime 동기화 이해
문제:
시간대로 날짜 및 시간 문자열을 구문 분석하려고 할 때 Python의 strptime() 함수를 사용하여 반환된 datetime 객체에 시간대 정보가 없다는 것을 확인했습니다. 설명서를 참조했음에도 불구하고 이 동작에 대한 문서화된 참조를 찾을 수 없습니다.
답변:
strptime()에 대한 설명서에서는 생략된 내용을 명시적으로 언급하지 않습니다. 시간대의 경우 자동으로 폐기하는 것으로 알려져 있습니다. 그러나 시간대를 정확하게 보존하기 위한 대체 솔루션이 있습니다.
해결책:
날짜 및 시간 문자열을 구문 분석하는 동안 시간대를 효과적으로 관리하려면 다음을 활용하는 것이 좋습니다. python-dateutil 모듈. 파서는 시간대를 포함한 포괄적인 날짜 형식 처리 기능을 제공합니다.
데모:
from dateutil import parser # Parsing a date with an explicit time zone parsed_datetime = parser.parse("Tue Jun 22 07:46:22 EST 2010") print(parsed_datetime.tzinfo) # Outputs 'tzlocal()' (local time zone)
결론:
By python-dateutil 파서를 사용하면 보존된 시간대를 사용하여 날짜 및 시간 문자열을 효율적으로 구문 분석할 수 있으므로 strptime()의 제한 사항과 씨름할 필요가 없습니다.
위 내용은 Python의 `strptime()`이 시간대를 보존하지 않는 이유는 무엇이며 최선의 대안은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Pythonusesahybridmodelofilationandlostretation : 1) ThePyThoninterPretreCeterCompileSsourcodeIntOplatform-IndependentBecode.

Pythonisbothingretedandcompiled.1) 1) it 'scompiledtobytecodeforportabilityacrossplatforms.2) thebytecodeisthentenningreted, withfordiNamictyTeNgreted, WhithItmayBowerShiledlanguges.

forloopsareusedwhendumberofitessiskNowninadvance, whilewhiloopsareusedwhentheationsdepernationsorarrays.2) whiloopsureatableforscenarioScontiLaspecOndCond

pythonisnotpurelynlogreted; itusesahybrideprophorfbyodecodecompilationandruntime -INGRETATION.1) pythoncompilessourcecodeintobytecode, thepythonVirtualMachine (pvm)

ToconcatenatelistsinpythonwithesameElements, 사용 : 1) OperatorTokeEpduplicates, 2) asettoremovedUplicates, or3) listComperensionForControlOverDuplicates, 각 methodHasDifferentPerferformanCeanDorderImpestications.

PythonisancerpretedLanguage, 비판적 요소를 제시하는 PytherfaceLockelimitationsIncriticalApplications.1) 해석 된 언어와 같은 thePeedBackandbackandrapidProtoTyping.2) CompilledlanguagesLikec/C transformt 해석

useforloopswhhenmerfiterationsiskNownInAdvance 및 WhileLoopSweHeniTesslationsDepoyConditionismet whilEroopsSuitsCenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTherInatismet, 유용한 광고 인 푸트 gorit


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

WebStorm Mac 버전
유용한 JavaScript 개발 도구

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

mPDF
mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구