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%H$N(B $B3:Ev%U%#!<%k%I$KJ8;zNs$G$O$J$/!"(BHeader $B%$%s%9%?%s%9$r(B $B;H$&$N$G$9!#(B Header$B%/%i%9$O(Bemail.header$B%b%8%e!<%k$+$i(B $B%$%s%]!<%H$7$F$/$@$5$$!#(B $B$?$H$($P(B:

>>> from email.message import Message
>>> from email.header import Header
>>> msg = Message()
>>> h = Header('p\xf6stal', 'iso-8859-1')
>>> msg['Subject'] = h
>>> print msg.as_string()
Subject: p$Bvs(Btal

Subject: $B%U%#!<%k%I$KHs(BASCII$BJ8;z$r$U$/$a$F$$$k$3$H$K(B $BCmL\$7$F$/$@$5$$!#$3$3$G$O!"4^$a$?$$%P%$%HNs$,%(%s%3!<%I$5$l$F$$$k(B $BJ8;z%;%C%H$r;XDj$7$F(B Header $B%$%s%9%?%s%9$r:n@.$9$k$3$H$K$h$C$F(B $BMessage $B%$%s%9%?%s%9$+$i(B $B%U%i%C%H$J%F%-%9%H$r@8@.$9$k$5$$$K!"$3$N(B Subject: $B%U%#!<%k%I$O(B RFC 2047 $B=`5r$NE,@Z$J7A<0$K%(%s%3!<%I$5$l$^$9!#(BMIME $B5!G=$N$D$$$F$$$k(B $B%a!<%i$J$i!"$3$N%X%C%@$KKd$a$3$^$l$?(B ISO-8859-1 $BJ8;z$r$?$@$7$/I=<($9$k$G$7$g$&!#(B

$B%P!<%8%g%s(B 2.2.2 $B$G(B $B?7$?$KDI2C(B $B$5$l$?;EMM$G$9!#(B

$B0J2<$O(B Header $B%/%i%9$N@bL@$G$9(B:

$B%/%i%9(B Header( [s[, charset[, maxlinelen[, header_name[, continuation_ws[, errors]]]]]])
$BJL$NJ8;z%;%C%H$NJ8;zNs$r$U$/$`(B MIME$B=`5r$J%X%C%@$r:n@.$7$^$9!#(B

$B%*%W%7%g%s0z?t(B s $B$O%X%C%@$NCM$N=i4|CM$G$9!#(B $B$3$l$,(B None $B$N>l9g(B ($B%G%U%)%k%H(B)$B!"%X%C%@$N=i4|CM$O@_Dj$5$l$^$;$s!#(B $B$3$NCM$O$"$H$+$i(B append() $B%a%=%C%I$r8F$S$@$9$3$H$K$h$C$F(B $BDI2C$9$k$3$H$,$G$-$^$9!#(Bs $B$O%P%$%HJ8;zNs$+!"$"$k$$$O(B Unicode $BJ8;zNs$G$b$+$^$$$^$;$s!#(B $B$3$N0UL#$K$D$$$F$O(B append() $B$N9`$r;2>H$7$F$/$@$5$$!#(B

$B%*%W%7%g%s0z?t(B charset $B$K$O(B 2$B$D$NL\E*$,$"$j$^$9!#(B $B$R$H$D$O(B append() $B%a%=%C%I$K$*$1$k(B charset $B0z?t$H(B $BF1$8$b$N$G$9!#$b$&$R$H$D$NL\E*$O!"$3$l0J9_(B charset $B0z?t$r(B $B>JN,$7$?(B append() $B%a%=%C%I8F$S=P$7$9$Y$F$K$*$1$k!"(B $B%G%U%)%k%HJ8;z%;%C%H$r7hDj$9$k$b$N$G$9!#%3%s%9%H%i%/%?$K(B charset $B$,M?$($i$l$J$$>l9g(B ($B%G%U%)%k%H(B)$B!"=i4|CM$N(B s $B$*$h$S(B $B0J8e$N(B append() $B8F$S=P$7$K$*$1$kJ8;z%;%C%H$H$7$F(B us-ascii $B$,;H$o$l$^$9!#(B

$B9T$N:GBgD9$O(B maxlinelen $B$K$h$C$FL@<(E*$K;XDj$G$-$^$9!#(B $B:G=i$N9T$r(B (Subject: $B$J$I$N(B s $B$K4^$^$l$J$$(B $B%U%#!<%k%I%X%C%@$N@UG$$r$H$k$?$a(B) $BC;$/@Z$j$H$k>l9g!"(B header_name $B$K$=$N%U%#!<%k%IL>$r;XDj$7$F$/$@$5$$!#(B maxlinelen $B$N%G%U%)%k%HCM$O(B 76 $B$G$"$j!"(Bheader_name $B$N(B $B%G%U%)%k%HCM$O(B None $B$G$9!#$3$l$O$=$N:G=i$N9T$r(B $BD9$$!"@Z$j$H$i$l$?%X%C%@$H$7$F07$o$J$$$3$H$r0UL#$7$^$9!#(B

$B%*%W%7%g%s0z?t(B continuation_ws $B$O(B RFC 2822$B=`5r$N(B $B@^$jJV$7MQM>GrJ8;z$G!"$U$D$&$3$l$O6uGr$+!"%O!<%I%&%'%"%?%VJ8;z(B (hard tab) $B$G$"$k(B $BI,MW$,$"$j$^$9!#$3$3$G;XDj$5$l$?J8;z$OJ#?t$K$o$?$k9T$N9TF,$KA^F~$5$l$^$9!#(B

$B%*%W%7%g%s0z?t(B errors $B$O!"(Bappend() $B%a%=%C%I$K$=$N$^$^EO$5$l$^$9!#(B

append( s[, charset[, errors]])
$B$3$N(B MIME $B%X%C%@$KJ8;zNs(B s $B$rDI2C$7$^$9!#(B

$B%*%W%7%g%s0z?t(B charset $B$,$b$7M?$($i$l$?>l9g!"$3$l$O(B Charset $B%$%s%9%?%s%9(B (email.charset $B$r;2>H(B) $B$+!"(B $B$"$k$$$OJ8;z%;%C%H$NL>A0$G$J$1$l$P$J$j$^$;$s!#$3$N>l9g$O(B Charset $B%$%s%9%?%s%9$KJQ49$5$l$^$9!#$3$NCM$,(B None $B$N>l9g(B ($B%G%U%)%k%H(B)$B!"(B $B%3%s%9%H%i%/%?$GM?$($i$l$?(B charset $B$,;H$o$l$^$9!#(B

s $B$O%P%$%HJ8;zNs$+!"(BUnicode $BJ8;zNs$G$9!#(B $B$3$l$P%P%$%HJ8;zNs(B (isinstance(s, str) $B$,??(B) $B$N>l9g!"(B charset $B$O$=$NJ8;zNs$N%(%s%3!<%G%#%s%0$G$"$j!"(B $B$3$l$,M?$($i$l$?J8;z%;%C%H$G$&$^$/%G%3!<%I$G$-$J$$$H$-$O(B UnicodeError $B$,H/@8$7$^$9!#(B

$B$$$C$]$&(B s $B$,(B Unicode $BJ8;zNs$N>l9g!"(Bcharset $B$O(B $B$=$NJ8;zNs$NJ8;z%;%C%H$r7hDj$9$k$?$a$N%R%s%H$H$7$F;H$o$l$^$9!#(B $B$3$N>l9g!"(BRFC 2822$B=`5r$N%X%C%@$O(B RFC 2047 $B$N5,B'$r$b$A$$$F:n@.$5$l!"(B Unicode $BJ8;zNs$O0J2<$NJ8;z%;%C%H$r(B ($B$3$NM%@h=g0L$G(B) $BE,MQ$7$F%(%s%3!<%I$5$l$^$9(B: us-ascii$B!"(B charset $B$GM?$($i$l$?%R%s%H!"$=$l$b$J$1$l$P(B utf-8$B!#(B $B:G=i$NJ8;z%;%C%H$O(B UnicodeError $B$r$J$k$Y$/$U$;$0$?$a$K;H$o$l$^$9!#(B

$B%*%W%7%g%s0z?t(B errors $B$O(B unicode() $BKt$O(B ustr.encode() $B$N8F$S=P$7;~$K;HMQ$7!"%G%U%)%k%HCM$O(B ``strict''$B$G$9!#(B

encode( [splitchars])
$B%a%C%;!<%8%X%C%@$r(B RFC $B$K1h$C$?$d$jJ}$G%(%s%3!<%I$7$^$9!#(B $B$*$=$i$/D9$$9T$O@^$jJV$5$l!"Hs(BASCII$BItJ,$O(B base64 $B$^$?$O(B quoted-printable $B%(%s%3!<%G%#%s%0$GJq4^$5$l$k$G$7$g$&!#(B $B%*%W%7%g%s0z?t(B splitchars $B$K$OD9$$(BASCII$B9T$rJ,3d$9$k(B $BJ8;z$NJ8;zNs$r;XDj$7!"(B RFC 2822 $B$N(Bhighest level syntactic breaks$B$N(B $BBg$^$+$J%5%]!<%H$N0Y$K;HMQ$7$^$9!#$3$N0z?t$O(B RFC 2047 $B$G%(%s%3!<%I(B $B$5$l$?9T$K$O1F6A$7$^$;$s!#(B

Header $B%/%i%9$O!"I8=`$N1i;;;R$dAH$_9~$_4X?t$r(B $B%5%]!<%H$9$k$?$a$N%a%=%C%I$b$$$/$D$+Ds6!$7$F$$$^$9!#(B

__str__( )
Header.encode() $B$HF1$8$G$9!#(B str(aHeader) $B$J$I$H$9$k$HM-MQ$G$7$g$&!#(B

__unicode__( )
$BAH$_9~$_$N(B unicode() $B4X?t$NJd=u$G$9!#(B $B%X%C%@$r(B Unicode $BJ8;zNs$H$7$FJV$7$^$9!#(B

__eq__( other)
$B$3$N%a%=%C%I$O!"$U$?$D$N(B Header $B%$%s%9%?%s%9$I$&$7$,Ey$7$$$+$I$&$+(B $BH=Dj$9$k$N$K;H$($^$9!#(B

__ne__( other)
$B$3$N%a%=%C%I$O!"$U$?$D$N(B Header $B%$%s%9%?%s%9$I$&$7$,0[$J$C$F$$$k$+$I$&$+$r(B $BH=Dj$9$k$N$K;H$($^$9!#(B

$B$5$i$K!"(Bemail.header $B%b%8%e!<%k$O0J2<$N$h$&$J(B $BJX59E*$J4X?t$bDs6!$7$F$$$^$9!#(B

decode_header( header)
$BJ8;z%;%C%H$rJQ49$9$k$3$H$J$7$K!"%a%C%;!<%8$N%X%C%@$r%G%3!<%I$7$^$9!#(B $B%X%C%@$NCM$O(B header $B$KEO$7$^$9!#(B

$B$3$N4X?t$O%X%C%@$N$=$l$>$l$N%G%3!<%I$5$l$?ItJ,$4$H$K!"(B (decoded_string, charset) $B$H$$$&7A<0$N(B 2$BMWAG%?%W%k$+$i$J$k(B $B%j%9%H$rJV$7$^$9!#(Bcharset $B$O%X%C%@$N%(%s%3!<%I$5$l$F$$$J$$ItJ,$K(B $BBP$7$F$O(B None $B$r!"$=$l0J30$N>l9g$O%(%s%3!<%I$5$l$?J8;zNs$,(B $B;XDj$7$F$$$kJ8;z%;%C%H$NL>A0$r>.J8;z$+$i$J$kJ8;zNs$GJV$7$^$9!#(B

$B0J2<$O$3$N;HMQNc$G$9(B:

>>> from email.header import decode_header
>>> decode_header('p$Bvs(Btal')
[('p\xf6stal', 'iso-8859-1')]

make_header( decoded_seq[, maxlinelen[, header_name[, continuation_ws]]])
decode_header() $B$K$h$C$FJV$5$l$k(B 2$BMWAG%?%W%k$N%j%9%H$+$i(B Header $B%$%s%9%?%s%9$r:n@.$7$^$9!#(B

decode_header() $B$O%X%C%@$NCM$r$H$C$F$-$F!"(B (decoded_string, charset) $B$H$$$&7A<0$N(B 2$BMWAG%?%W%k$+$i$J$k(B $B%j%9%H$rJV$7$^$9!#$3$3$G(B decoded_string $B$O%G%3!<%I$5$l$?J8;zNs!"(B charset $B$O$=$NJ8;z%;%C%H$G$9!#(B

$B$3$N4X?t$O$3$l$i$N%j%9%H$N9`L\$+$i!"(BHeader $B%$%s%9%?%s%9$rJV$7$^$9!#(B $B%*%W%7%g%s0z?t(B maxlinelen$B!"(Bheader_name $B$*$h$S(B continuation_ws $B$O(B Header $B%3%s%9%H%i%/%?$KM?$($k$b$N$HF1$8$G$9!#(B

$B$40U8+$d$4;XE&$r$*4s$;$K$J$j$?$$J}$O!"(B $B$3$N%I%-%e%a%s%H$K$D$$$F(B... $B$r$4Mw$/$@$5$$!#(B