나는 strftime, strptime 및 timedelta와 같이 datetime 모듈의 다양한 함수를 사용하는 함수를 만들려고합니다.Python 정의 전역 이름 datetime
는 내가 모든 노력을 한 것 같은 느낌,하지만 때마다 나는이 말된다 :
4 date = '2012.09.07'
5
----> 6 q = net(date)
7 print q
/Users/fb/Documents/Python_files/test_function.pyc in net(date)
1 def net(date):
----> 2 b = datetime.strptime(a, '%Y.%m.%d')
3 c = b.strftime('%d:%m:%y')
4 return c
NameError: global name 'datetime' is not defined
나는, 즉 '그것은 파이썬 인터프리터에서 작동 다른 사람은 아마 같은 문제가 발생 읽었습니다 하지만 스크립트에는 없습니다 '. 아무도 도와 줄 수 있니?
여기서'a' 변수는 무엇입니까? b = datetime.strptime (a, '% Y. % m. % d')'? –