質問編集履歴
2
タグ
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         
            File without changes
         
     | 
1
エラー
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         @@ -8,18 +8,18 @@ 
     | 
|
| 
       8 
8 
     | 
    
         
             
            UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-7: ordinal not in range(128)
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            ```
         
     | 
| 
       11 
     | 
    
         
            -
            エラーメッセージ
         
     | 
| 
       12 
     | 
    
         
            -
            ```
         
     | 
| 
       13 
     | 
    
         
            -
            UnicodeEncodeError 
     | 
| 
      
 11 
     | 
    
         
            +
            UnicodeEncodeError Traceback (most recent call last)
         
     | 
| 
       14 
12 
     | 
    
         
             
            <ipython-input-2-48e1f5c98f61> in <module>
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
            30 filename = part.get_filename()
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
            31 if not filename:
         
     | 
| 
       17 
     | 
    
         
            -
            ---> 32 
     | 
| 
      
 15 
     | 
    
         
            +
            ---> 32 body = base64.urlsafe_b64decode(part.get_payload().encode('ASCII')).decode('utf-8')
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
            33 print(f"本文:{body}")
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
            34 else:
         
     | 
| 
       20 
18 
     | 
    
         | 
| 
       21 
19 
     | 
    
         
             
            UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-7: ordinal not in range(128)
         
     | 
| 
      
 20 
     | 
    
         
            +
            ```
         
     | 
| 
       22 
21 
     | 
    
         | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       23 
23 
     | 
    
         
             
            ```python
         
     | 
| 
       24 
24 
     | 
    
         
             
            import imaplib
         
     | 
| 
       25 
25 
     | 
    
         
             
            import email
         
     |