نحوه خواندن یکdictionary به صورت key , value در python

برای خواندن یه dictionary به صورت key , value ، به شکل زیر عمل کنید:

x = {"name":"AcharCode", "for":"Developers" }
for key,value in x.items():
    print(key , value)

در کد بالا با استفاده از متد ()items تونستیم به صورت key , value به محتویات یه dictionary دسترسی داشته باشیم.

خروجی به صورت زیر خواهد بود:

name AcharCode
for Developers

منبع : reference( بعد از رفتن به صفحه جدید روی گزینه skip کلیک کنید تا به صفحه اصلی بروید.)

تبدیل اعداد فارسی به انگلیسی در پایتون

کتابخانه Unidecode رو به صورت زیر نصب کنید:

python -m pip install Unidecode

(اگر به مشکل زیر برخوردید vpn رو روشن کنید و نصب کنید)

ARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError....

در پایتون 2 :

>>> from unidecode import unidecode
>>> a = unidecode(u"۰۱۲۳۴۵۶۷۸۹")
>>> a
'0123456789'
>>> unidecode(a)
'0123456789'

در پایتون3 :

>>> from unidecode import unidecode
>>> a = unidecode("۰۱۲۳۴۵۶۷۸۹")
>>> a
'0123456789'
>>> unidecode(a)
'0123456789'

reference to: click

(help to click)

حل مشکل ERROR: Could not find a version that satisfies the requirement در پایتون

کتابخونه PyAutoIt رو نصب میکردم که با ارور زیر مواجه شدم:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000022EF4A241F0>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/pyautoit/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000022EF4A24730>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/pyautoit/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000022EF4A64160>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/pyautoit/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000022EF4A64310>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/pyautoit/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000022EF4A644C0>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/pyautoit/
ERROR: Could not find a version that satisfies the requirement pyautoit (from versions: none)
ERROR: No matching distribution found for pyautoit

احتمال زیاد آی پی ایران رو تحریمه. من با باز کردن یه فیلترشکن مشکلم حل شد.

Reference : AcharCode.ir