0
이상한 동작이 있습니다. 내 코드는 Eclipse-Pydev에서 작동하지만 Unix에서는 작동하지 않습니다. 누군가 내가 잘못 가고 있다고 조언 할 수 있습니까? 이클립스의 PyDev에서 유닉스에서문자열 형식 지정 오류 - 파이썬
코드
#!/usr/bin/python
def myDisplay(Message,File):
print "Message",Message
print len(Message)
print "File",File
print "**",'{:^48}'.format(Message),"**"
print "**",'{:^48}'.format(File),"**"
myDisplay('Success','ABC.2013-07-05_00:00:00.txt')
오류
Message Success
7
File ABC.2013-07-05_00:00:00.txt
**
Traceback (most recent call last):
File "DailyCheck.py", line 8, in <module>
myDisplay('Success','ABC.2013-07-05_00:00:00.txt')
File "DailyCheck.py", line 6, in myDisplay
print "**",'{:^48}'.format(Message),"**"
ValueError: zero length field name in format
출력
Message Success
7
File ABC.2013-07-05_00:00:00.txt
** Success **
** ABC.2013-07-05_00:00:00.txt **
내가 어디로 잘못 가고 있는지 혼란 스럽다. 형식의 필드 이름이 길이가 0이 아니므로 오류가 발생하는 이유는 무엇입니까?
감사합니다. 어떤 버전부터 [:^48]로 작동합니까? – misguided
단일 매개 변수에 대한 위치 인수는 2.7 이후에서 생략 될 수 있습니다. –