I have a problem with encoding with russian language for my python script [duplicate]

2024/11/20 21:35:45

I am trying to send an email from my python project. But my method doesn't work with russian language.

import smtplibserver = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('[email protected]', 'pasword')
server.sendmail('[email protected]', '[email protected]', 'привет')
server.quit()

I have this error: UnicodeEncodeError: 'ascii' codec can't encode character in position 0-4: ordinal not range(128) For English it is working. Python 3.6

Answer
server.sendmail('email.com', 'email.com', 'привет'.encode('utf-8'))
https://en.xdnf.cn/q/119788.html

Related Q&A

how do you style data frame in Pandas

I have this data frame: dfServer Env. Model Percent_Utilized server123 Prod Cisco. 50 server567. Prod Cisco. 80 serverabc. Prod IBM. 100 serverdwc.…

Vacation price program Python [closed]

Closed. This question needs debugging details. It is not currently accepting answers.Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to repro…

Why did push of a Flask app to Heroku failed?

Im simply trying to push my Flask app to Heroku but I encountered the following error: remote: ERROR: Command errored out with exit status 1: remote: command: /app/.heroku/python…

How to navigate through HTMl pages that have paging for their content using Python? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 6 years ago.Improve…

How to merge one list elements with another list elements in python? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 3 years ago.Improve…

Display and play audio files

I am new to python, and Im trying to build a simple recording program. With the some help from my previous question, I was able to add a timestamp for each recorded fileEDIT:I did some research and dec…

Web Scraping BeautifulSoup - Next Page parsing

Im just learning web scraping & want to output the result of this website to a csv file https://www.avbuyer.com/aircraft/private-jets but am struggling with parsing the next pages here is my code (…

convert sum value to percentage by userid django

Im trying to convert the total sum to a percentage by userid but an error pops up when I try to run the following program. The error is: name mark is not definedBelow is my code for views.pydef attStud…

ValueError: Too many values to unpack

Task is to find,sort,and remove the student with type: "homework" and with the lowest score using MongoDB. I also tried to use toArray() function,but it gave an error. Now I try to move on in…

Pandas - Create dynamic column(s) from a single columns values

I have JSON data which I am planning after converting it to desired dataframe, will concat with another dataframe. Participant**row 1** [{roles: [{type: director}, {type: founder}, {type: owner}, {type…