فارسی
باز کردن در Telegram
PPythonHost.ir | پایتون هاست

PythonHost.ir | پایتون هاست

@pythonhost_ir · کانال · ایندکس از 2026-07-19
61مشترک
34میانگین دسترسی پست
9پست در 30 روز
43پست در ایندکس
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
فشرده‌سازی سریع با gzip #پایتون import gzip data=b'hello'*200 z=gzip.compress(data) print(len(data),'->',len(z)) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
65 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
ساخت zip داخل حافظه #پایتون import io, zipfile buf=io.BytesIO() with zipfile.ZipFile(buf,'w') as z: z.writestr('a.txt','hello') print('bytes:', len(buf.getvalue())) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
71 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
ساخت tar.gz #پایتون import tarfile with tarfile.open('a.tar.gz','w:gz') as t: t.add('out.txt') print('ok') PythonHost.ir | پایتون هاست @pythonhost_ir ‌
61 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
پار‌س URL #پایتون from urllib.parse import urlparse u=urlparse('https://example.com/a?x=1') print(u.netloc, u.path, u.query) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
64 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
ساخت Query String #پایتون from urllib.parse import urlencode print(urlencode({'q':'python','page':2})) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
71 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
درخواست ساده HTTP با urllib #پایتون from urllib.request import urlopen print(urlopen('https://example.com').status) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
79 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
پارس JSON #پایتون import json data=json.loads('{"a":1,"b":2}') print(data['a']) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
82 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
Pretty JSON #پایتون import json print(json.dumps({'a':1,'b':[1,2]}, ensure_ascii=False, indent=2)) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
90 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
خواندن CSV با DictReader #پایتون import csv, io f=io.StringIO('a,b\n1,2\n') print(next(csv.DictReader(f))) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
87 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
نوشتن CSV #پایتون import csv, io buf=io.StringIO() w=csv.writer(buf) w.writerow(['name','age']) w.writerow(['Ali',20]) print(buf.getvalue()) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
94 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
SQLite: ساخت جدول و درج #پایتون import sqlite3 con=sqlite3.connect(':memory:') con.execute('create table t(x int)') con.execute('insert into t values (1)') print(con.execute('select x from t').fetchone()[0]) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
106 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
SQLite: Row به شکل dict #پایتون import sqlite3 con=sqlite3.connect(':memory:') con.row_factory=sqlite3.Row row=con.execute('select 1 as a, 2 as b').fetchone() print(dict(row)) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
132 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
shelve: ذخیره key/value #پایتون import shelve with shelve.open('kv.db') as db: db['token']='abc' print(db['token']) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
155 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
pickle: سریال‌سازی #پایتون import pickle b=pickle.dumps({'a':1}) print(pickle.loads(b)) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
191 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
Decimal برای دقت مالی #پایتون from decimal import Decimal print(Decimal('0.1')+Decimal('0.2')) PythonHost.ir | پایتون هاست @pythonhost_ir ‌
1 · 211 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
آموزش pickle برای داده قابل‌اعتماد محلی #پایتون import pickle payload = {"a": 1, "items": [1, 2, 3]} blob = pickle.dumps(payload, protocol=pickle.HIGHEST_PROTOCOL) print(pickle.loads(blob)) # هشدار: pickle داده‌ی ناشناس یا اینترنتی را load نکنید. pythonhost.ir | پایتون هاست @pythonhost_ir‌ ‌
37 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
آموزش Regex: استخراج ساده الگوهای شبیه ایمیل #پایتون import re text = "[email protected] test [email protected]" pattern = r"[\w.+-]+@[\w.-]+\.[A-Za-z]{2,}" print(re.findall(pattern, text)) # برای اعتبارسنجی واقعی ایمیل، Regex ساده کافی نیست. pythonhost.ir | پایتون هاست @pythonhost_ir‌ ‌
29 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
آموزش Regex: replace چند فاصله #پایتون import re s = 'a b c' print(re.sub('\\s+', ' ', s).strip()) pythonhost.ir | پایتون هاست @pythonhost_ir‌ ‌
26 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
نرمال‌سازی یونیکد NFKC #پایتون import unicodedata print(unicodedata.normalize('NFKC', 'ABC')) pythonhost.ir | پایتون هاست @pythonhost_ir‌ ‌
28 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
چیدن متن در عرض مشخص (wrap) #پایتون import textwrap print(textwrap.fill('این یک متن خیلی طولانی است', width=10)) pythonhost.ir | پایتون هاست @pythonhost_ir‌ ‌
2 · 151 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
آموزش escape HTML #پایتون import html print(html.escape('<a href="x">hi</a>')) pythonhost.ir | پایتون هاست @pythonhost_ir‌ ‌
14 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
آموزش diff دو متن با difflib #پایتون import difflib a = 'hello\nworld\n' b = 'hello\nWORLD\n' print(''.join(difflib.unified_diff(a.splitlines(True), b.splitlines(True)))) pythonhost.ir | پایتون هاست @pythonhost_ir‌ ‌
11 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
آموزش Top-N با heapq #پایتون import heapq xs = [5, 1, 9, 2, 7] print(heapq.nlargest(3, xs)) pythonhost.ir | پایتون هاست @pythonhost_ir‌ ‌
8 ·
P
PythonHost.ir | پایتون هاست
عکس
برای نمایش کلیک کنید
آموزش binary search با bisect #پایتون import bisect xs = [1, 3, 5, 7] print(bisect.bisect_left(xs, 6)) pythonhost.ir | پایتون هاست @pythonhost_ir‌ ‌
6 ·

فید عمومی باز از ایندکس جست‌وجو ChatCrawler — «Google برای Telegram عمومی»؛ با خزش انجمن به‌روز می‌شود. زمان‌ها به UTC است.

فقط محتوای عمومی، API رسمی Telegram. دربارهٔ ما · پرسش‌ها · محدودیت‌های ایندکس · حذف یک صفحه · کاتالوگ · جست‌وجو · روش محاسبهٔ ما